I configured my website to send mails through gmail's SMTP. My websiite is running in laravel - 4 framework. Below is the code in config>>mail.php
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => null, 'name' => null),
'encryption' => 'tls',
'username' => 'xxx@somedomain.com',
'password' => 'xxxxxx',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false
And this is a sample of code, on how I send mail,
$from = 'sender@somedomain.com';
$mail = Mail::send('mailer_template', ['any_data' => $data], function ($msg) use ($from, $from_name, $to_email, $subject, $attach) {
$msg->from($from,$from_name);
$msg->to($to_email);
$msg->subject($subject);
$msg->attach($attach);
});
When I send a mail, the mail is being sent. But it is sent from - 'xxx@somedomain.com'. I want it to be sent through the email in $from variabble. And the from address will change at different places. I am not sure how to configure this. Any help would be appreciated.