I'm trying to add multiple mail driver
I have two emails in same Host Server One for financial messages The second is for regular messages
.env file
MAIL_MAILER_1=smtp
MAIL_HOST_1=mail.privateemail.com
MAIL_PORT_1=465
[email protected]
MAIL_PASSWORD_1=example(Lw8S
MAIL_ENCRYPTION_1=ssl
[email protected]
MAIL_FROM_NAME_1="${APP_NAME}"
MAIL_MAILER_2=smtp
MAIL_HOST_2=mail.privateemail.com
MAIL_PORT_2=465
[email protected]
MAIL_PASSWORD_2=example$7Sweffake
MAIL_ENCRYPTION_2=ssl
[email protected]
MAIL_FROM_NAME_2="${APP_NAME}"
mail.php file
'mail_payments' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST_1', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT_1', 587),
'encryption' => env('MAIL_ENCRYPTION_1', 'tls'),
'username' => env('MAIL_USERNAME_1'),
'password' => env('MAIL_PASSWORD_1'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST_2', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT_2', 587),
'encryption' => env('MAIL_ENCRYPTION_2', 'tls'),
'username' => env('MAIL_USERNAME_2'),
'password' => env('MAIL_PASSWORD_2'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
Mail_Paid_Profits_Controller.php file
public function send_form(Request $request){
$name = $request->input('name');
$email = $request->input('email');
$amount = $request->input('amount');
$note = $request->input('note');
$image = $request->file('image');
$date_now = Carbon::now()->format('Y-m-d');
$mailData = [
'title' => "Hello $name , we have sent you your earnings",
'body' => "On $date_now, we paid you $$amount as a payment from your monthly earnings.",
'note' => $note,
'image' => $image
];
Mail::mailer('mail_payments')->to($email)->send(new Paid_Profits($mailData));
Session::flash('message', "Sent successfully");
return redirect()->back();
}
One for financial messages The second is for regular messages
When I add the MAIL_MAILER_1 data in the MAIL_MAILER_2, it works successfully, which means that the .env file data is correct
I mean, when I add the financial messages data in the regular messages becasue it default SMTP , it works, but when I add it in a new data in the MAIL_MAILER_1 and use it , it does not work
I searched a lot and did not know the problem Knowing that it is not a fault DNS as I said it works Via default SMTP But when I add it as a second MAIL_MAILER_1 it doesn't work and I get this error: and run :
php artisan config:clear
php artisan cache:clear
Expected response code "250/251/252" but got code "550", with message "550 5.7.27 [email protected]: Sender address rejected: Domain example.com does not accept mail (nullMX)".
error line :
Mail::mailer('mail_payments')->to($email)->send(new Paid_Profits($mailData));
I suspect that there is an error in the mail.php or Mail_Paid_Profits_Controller file
