Reputation: 13
Already read a lot and even did php artisan config:clear Checked thourghout all files and [email protected] is nowhere.
It works from local w/o problems.
Also, have another app in plain PHP that uses PHPMailer and this issue does not happen so I don't think it would be something related to the server.
Any help appreciated hence this script is only waiting this issue to be solved so it can be live.
UPDATE: The issue was with the mail server. We changed the mail server to a different machine but didn't configure completely the DNS.
Thanks to both for answering.
Upvotes: 1
Views: 1005
Reputation: 1073
1)First of all you have to set the environment variable in .env file
MAIL_DRIVER=mail
MAIL_HOST=mail.abc.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=abc123
MAIL_ENCRYPTION=null
2) Then import this in your controller,
use Illuminate\Support\Facades\Mail;
3) Then add this function in your controller,
public function basic_email() {
$data = array('name'=>"Virat Gandhi");
Mail::send(['text'=>'mail'], $data, function($message) {
$message->from('[email protected]');
$message->subject('Testing');
$message->to('[email protected]');
echo "Basic Email Sent. Check your inbox.";
});
4) I hope this helped you.
Upvotes: 0
Reputation: 891
Email address is configured in config/mail.php file
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
but how you can see it is using environment vars configured in .env in root directory
[email protected]
MAIL_FROM_NAME="San Marino Pastas"
Remeber if you are using artisan serve or queue listining restart the services to take the new config.
Please try this and let me know how it works :)
Upvotes: 1