How to send laravel notification to a custom email - laravel

I have a laravel application,
I send notifications to a user when he registers. I use the notify() on the model. But I have an issue, How do i send a notification to a custom email address? the same notification.
Here's what i have:
`$admin = Admin::find(1);
$admin->email = 'admin#site.com';
$admin->notify((new NewUserRegistered($user))->delay($when));
$user->notify((new UserRegistered($user))->delay($when));`
i get a user model instance, and customize the email to input the custom email... However, the email sends to the original mail on the model and ignores the edit.
How do i do this please?

Here the code snippet you can use for sending the notification directly to an email address without creating the User or without having the User in the database.
Notification::route('mail', 'me#abdulrehman.pk')->notify(new InvoicePaid($invoice));

As a work around, you can save the model before sending the message
$admin->email = 'admin#site.com';
$admin->save();
after that you can retrieve the email as it was

Related

Laravel 5.8 : mail notification for a user with no email value doesn't fail?

In classic way, a registered or activated user will necessarily always have an email.
In my specific context we have to deal with few users with no email address. The activation relies on many fields already in database, and email is not necessarily needed.
In this context, anyway we have to send notifications campaign to users to send them informations.
I deal with the fail function to retrieves failed notifications and list them on an interface.
The problem I'm facing is with users without any email.
I was expecting that sending a notification to a user without any email address would fail but it's not the case. I need to be able to add those users to the failed notifications list...
The notification just goes its way with no fail.
Am I missing something here?
Sorry, I should have been more specific:
The notification use a notification class that sends notification via mail and database with queuing.
Each notification is recorded in database and has a state into its 'data' field set to 'OK' when it goes well or 'FAILED' when it fails.
I've solved the problem by managing throw the loop: if the user has no email then the notification mail is not sent and the notification is created manually into the database with the 'FAILED' flag via a custom method 'force_mark_notification_as_failed'.
foreach ($users as $user) {
if ($user->email != '') {
$when = $when->addSeconds(1);
$user->notify((new MailNotificationManager($campaign_id, $users_amount, 'releve_notes', $user->email))->delay($when));
} else {
$this->force_mark_notification_as_failed($campaign_id, $users_amount, $user->id);
}
}

Stripe webhook for laravel

Please ask if you don't understand anything....I am creating stripe subscription payment. i need to handle stripe customer.subscription.deleted event. i have created a webhook for it in my laravel app. but the thing is whenever i send test data from stripe it shows webhook handled. but i am sending email whenever payment is unsuccessful and also logging this it is not showing in log or sending email. I am hosting my website for now using ngrok.. which is build in in laragon.
My controller method
use Laravel\Cashier\Http\Controllers\WebhookController;
class SubscriptionController extends WebhookController
{
public function handleCustomerSubscriptionDeleted($payload){
\Log::info("Webhook is working");
dd($payload);
}
}
my route file is like this
Route::get('/stripe/webhook','SubscriptionController#handleWebhook');
it is not showing in log file this neither it is sending email.
i am following this article please check if it is right way to do this??
Click here
I have added dd() here how does this webhook will be successful?

Laravel Mail or Notification? which one should use for email sending? and Why?

I'm new in laravel. I have to use email feature in my project. In Laravel Docs, I got Mail and Notification options for sending email feature. Now I want to know which one should be used and why?
Please Note: I will use ShouldQueue as well.
If you want to send the information via just one channel, say email only, then use Mailable. If you are likely to send the information as email or SMS, some other medium or multiple(eg. email and SMS), your best bet is to use Notification.
You should use Mailable, if each email you send out has different layout. Mailable is a very flexible way to send emails. And it's more customizable than Notification.
Notification is useful if you have to send a predefined layout in differents channel.
You can customize notifications layout, but it's not advisable as it's out of scope to have more than one layout of notification.
According to this laracasts video
"a general rule of thumb, what's nice about Notifications is you are notifying the user in response to some action that took place on the website, so they made a payment, they close their account they liked something these are all responses to an action."
I use the Mail facade for marketing, for example: to inform the new features in our website, inform some special day is coming soon, etc.

is it possible to notify all users using Laravel notification with pusher?

Is it possible to create/send notification(s) to all users when there is new announcement.
I want all users to be notified using the database notification.
Since most of the tutorials I have seen are all email notification, is this possible? Please attach links or any idea on how I could implement this.
Literally in the documentation:
Alternatively, you may send notifications via the Notification facade.
This is useful primarily when you need to send a notification to
multiple notifiable entities such as a collection of users. To send
notifications using the facade, pass all of the notifiable entities
and the notification instance to the send method:
Notification::send($users, new InvoicePaid($invoice));
So yes, you can send to all user by getting them from the database and sending a notification using the facade.
For example:
Notification::send(User::all(), new InvoicePaid($invoice));

Customer not receiving the place order and form submission mail with details (Magento)

I'm trying to configure email in my magento website. My website is https://tumree.com. I just enabled contacts in system->configuration.
Send Emails To : admin#tumree.com and Email Sender: Custom Email 2.
In store email adress, In Custom email 2, sender name: Tumree admin and sender email:admin#tumree.com
When I'm trying to fill out the forms and submit, the msg "Form is submitted successfully". The account admin#tumree.com receives the email with customer name,email,number,comment.
But the customer who is filled out the form with name,email etc., not receiving the mail.
I enabled in the mail settings for return-path-> yes. But I dint reflect anything. when the order is placed, the customer not receiving the mail too with order details. Pls help me here....enter link description here
To send emails out of your server, you probably need to do it with smtp . Your server sends emails ("Form is submitted successfully")but they are rejected from the target server. Try it with https://www.magentocommerce.com/magento-connect/smtp-pro-email-free-custom-smtp-email.html or something related.

Resources