laravel - multiple mail configurations -
i configured laravel's mail service service mandrill driver. no problems here!
now, @ point of application, need send mail service via gmail.
i did like:
// backup current mail service configs $backup = config::get('mail'); // rewrite mail service configs gmail stmp $new_configs = array( 'driver' => 'smtp', // ... other configs here ); config::set('mail', $new_configs); // send email mail::send(... // restore configs config::set('mail', $backup);
this doens't work, laravel uses mandrill configurations. looks initiates mail service service @ script startup , ignores whatever during execution.
how alter mail service service configs/behaviour during execution?
you can create new swift_mailer
instance , utilize that:
// backup default mailer $backup = mail::getswiftmailer(); // setup gmail mailer $transport = swift_smtptransport::newinstance('smtp.gmail.com', 465, 'ssl'); $transport->setusername('your_gmail_username'); $transport->setpassword('your_gmail_password'); // other mailer configuration stuff needed... $gmail = new swift_mailer($transport); // set mailer gmail mail::setswiftmailer($gmail); // send message mail::send(); // restore original mailer mail::setswiftmailer($backup);
laravel laravel-4
No comments:
Post a Comment