本文实例讲述了yii2使用swiftmailer发送邮件的方法。分享给大家供大家参考,具体如下:
'mail' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@backend/mail',
'useFileTransport' => false,//set this property to false to send mails to real email addresses
//comment the following array to send mail using php's mail function
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => 'username@gmail.com',
'password' => 'password',
'port' => '587',
'encryption' => 'tls',
],
],
],
控制器:
Yii::$app->mail->compose('your_view', ['params' => $params])
->setFrom([\Yii::$app->params['supportEmail'] => 'Test Mail'])
->setTo('to_email@xx.com')
->setSubject('This is a test mail ' )
->send();
更多关于Yii相关内容感兴趣的读者可查看本站专题:《Yii框架入门及常用技巧总结》、《php优秀开发框架总结》、《smarty模板入门基础教程》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
DBShop电子商务系统具备统一的系统设置、简单的商品管理、灵活的商品标签、强大的商品属性、方便的配送费用管理、自由的客服设置、独立的广告管理、全面的邮件提醒、详细的管理权限设置、整合国内外知名支付网关、完善的系统更新(可在线自动更新或手动更新)功能、细致的帮助说明、无微不至的在线教程……,使用本系统绝对是一种享受! DBShop开源电子商务网店系统采用业界知名框架 ZendFramewor
401
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号