I tried to mail using default mail of swift mailer but didn't receive any mail.
here is my config
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail/views',
'useFileTransport' => true,
'enableSwiftMailerLogging' => true,
]
and here is code for send mail
\Yii::$app->mailer->compose('deleteMailTemplate',[
'name' => "Peter",
])
->setFrom("contact-atd@gmail.com")
->setTo("Peter.p@gmail.com")
->setSubject('Delete reminder mail')
->send();
I don't know what's the issue please help thanks in advance.
I think you have issue in email configuration. Please used following code and check i hope this will work.
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => 'username',
'password' => 'password',
'port' => '465',
'encryption' => 'ssl',
],
],
$sendemail = Yii::$app->mailer->compose()
->attach(attachment path)
->setFrom(From Email)
->setTo($email)
->setSubject($subject)
->setHtmlBody($emailBody)
->send();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.