I have a correct email address. I have echoed it, but when I send it, I get the following error:
Address in mailbox given [] does not comply with RFC 2822,
I had very similar problem today and solution was as it is..
$email = Array("Zaffar Saffee" => "myemail@gmail.com");
$schedule->command('cmd:mycmd')
->everyMinute()
->sendOutputTo("/home/forge/dev.mysite.com/storage/logs/cron.log")
->emailWrittenOutputTo($email);
It laravel 5.2 though...
my basic problem was , I was passing string instead of array so, error was
->emailWrittenOutputTo('mymail@gmail.com'); // string, we need an array
Its because the email address which is being sent is blank. see those empty brackets? that means the email address is not being put in the $address of the swiftmailer function.
Try this.
Mail::send('emails.activation', $data, function($message) use($email,$subject){
$message->to($email)->subject($subject);
});
->with('title', "Registered Successfully.");
Your problem may be that the .env file is not loading properly and using the MAIL_USERNAME.
To check if your .env file is loading the email address properly add this line to your controller and refresh the page.
dd(env('MAIL_USERNAME')
If it shows up null try running the following command from command line and trying again.
php artisan cache:clear
(I'm using SwiftMailer in PHP)
I was getting an error like that when I was accidentally sending a string for $email
$email = "someone@somewhere.com <Some One>";
When what I meant to be sending was
$email = Array("someone@somewhere.com"=>"Some One");
I was accidentally running it through a stringify function that I was using for logging, so once I started sending the array again, the error went away.
The only solution worked for me is changing the following code
Mail::send('emails.activation', $data, function($message){
$message->from(env('MAIL_USERNAME'),'Test');
$message->to($email)->subject($subject);
});