Skip to content

Instantly share code, notes, and snippets.

@kishor10d
Last active May 11, 2018 12:50
Show Gist options
  • Save kishor10d/b381dee484d9b9242fd52aa1d68f0ab7 to your computer and use it in GitHub Desktop.
Save kishor10d/b381dee484d9b9242fd52aa1d68f0ab7 to your computer and use it in GitHub Desktop.
public static function emailTemplate($viewName = '', $toEmail = '', $subject = '', $dataToSend = array())
{
$from = \Yii::$app->params['FROM_EMAIL'];
$bcc_email = \Yii::$app->params['BCC_EMAIL'];
\Yii::$app->mailer->compose($viewName, $dataToSend)
->setFrom($from)
->setTo($toEmail)
->setBcc($bcc_email)
->setSubject($subject)
->send();
}
<?php
return [
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com', // e.g. smtp.mandrillapp.com or smtp.gmail.com
'username' => '[email protected]', // my email id
'password' => 'xxxxxxxxx', // my password
'port' => '465', // Port 25 is a very common port too
'encryption' => 'ssl', // It is often used, check your provider or mail server specs
],
],
]
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment