Laravel 5: Sending Email

Laravel 5 sending mail to multiple users at once

$allmails = array_push($array, $mail->email); is wrong

Right answer is just array_push($array, $mail->email);

array_push($array, $mail->email); this is returning an array.

$allmails = array_push($array, $mail->email);
But this is returning int value.

Sending email to multiple cc recipients in Laravel 5.4

The setAdress() function in Mailable allow you to give an array as argument:

Mailable.php

So You should be able to use the function by passing an array as your argument

Mail::to($email)
->cc(['name1@example.com','name2@example.com'])
->send(new document());

Laravel Mail::send() sending to multiple to or bcc addresses

I've tested it using the following code:

$emails = ['myoneemail@esomething.com', 'myother@esomething.com','myother2@esomething.com'];

Mail::send('emails.welcome', [], function($message) use ($emails)
{
$message->to($emails)->subject('This is test e-mail');
});
var_dump( Mail:: failures());
exit;

Result - empty array for failures.

But of course you need to configure your app/config/mail.php properly. So first make sure you can send e-mail just to one user and then test your code with many users.

Moreover using this simple code none of my e-mails were delivered to free mail accounts, I got only emails to inboxes that I have on my paid hosting accounts, so probably they were caught by some filters (it's maybe simple topic/content issue but I mentioned it just in case you haven't received some of e-mails) .

laravel 5 smtp mail not sending even after changing less secure app

After long research it is found that laravel mail not worked with tls but ssl is fine. so after changing setting as follows it works
.env file

MAIL_DRIVER=smtp
MAIL_ADDRESS=rejoanul.alam@gmail.com
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_PASSWORD=myPass (this should be app password)
MAIL_ENCRYPTION=ssl

normally your email password will not work. generate a app password from here https://security.google.com/settings/security/apppasswords
Note: without 2 step verification enable perhaps app password not work



Related Topics



Leave a reply



Submit