I can send email from tinker but when I try to send email from code in laravel framework I get below error:
Swift_TransportException (550)
Expected response code 250 but got code "550", with message "550 Bad HELO - Host impersonating domain name [mydomain.com] "
This is my simple mail method to test sending email from laravel controller :
Mail::send('errors.401', [], function ($message) { $message->to('[email protected]')->subject('this works!'); });
.env file:
MAIL_DRIVER=smtp
MAIL_HOST=mail.mydomain.com
MAIL_PORT=587
MAIL_USERNAME=in[email protected]
MAIL_PASSWORD=<password>
MAIL_ENCRYPTION=
I've done below steps but still it doesn't work:
composer dump-autoload
php artisan view:clear
php artisan cache:clear
php artisan config:cache
Update:
My code is on an ubuntu server which I configured dns server and bind9 to connect domain to server and I have an external mail server to handle emails.
So whenever an email request is created in ubuntu server, it'll forward it to external mail server.
where should I look for problem?