Yii framework sending email via Gmail! No need smtp locally!!!!
Step 1: Download email ext. from Yii website: http://www.yiiframework.com/extension/email/, extracting and putting it under protected/extension.
e.g., protected/extension/mail/ - doc
- vendors
- YiiMail.php
- YiiMailMessage.php
Step 2: Config your mail.php by refering gmail config direction (http://support.google.com/mail/bin/answer.py?hl=en&answer=13287)
e.g., You can easily copy the following code into your project!!!
'mail' => array(
'class' => 'ext.mail.YiiMail',
'transportType' => 'smtp',
'transportOptions'=>array(
'host'=>'smtp.gmail.com',
'encryption'=>'ssl', // use ssl
'username'=>'xxxx@gmail.com',
'password'=>'xxxxxx',
'port'=>465, // ssl port for gmail
),
'viewPath' => 'application.views.mail',
'logging' => true,
'dryRun' => false
),
Step 3: Put the real logic in your view file or controller.
e.g.,
$message = new YiiMailMessage;
$message->setBody('Message content here with HTML', 'text/html');
$message->subject = 'My Subject';
$message->addTo('xxxx@xxxx');
$message->from = "xxxxxx@gmail.com";//Yii::app()->params['adminEmail'];
Yii::app()->mail->send($message);
帮自己宣传一下刚上线的网站 梦奇网;目前的提供的服务是 签证搜索 和 时间和日期。谢谢大家支持,SEO下!
Thank you very much Great And Simple, It is very useful forme
ReplyDeleteI got this issue:
ReplyDeleteProperty "CWebApplication.mail" is not defined.
Did you forget importing the extension?
Delete'import' => array( 'Ext.yii-mail.*',
)
Oops...You are right! thanks
DeleteI already insert the 'import' => array( 'Ext.yii-mail.*',
Delete) but still the error Property "CWebApplication.mail" is not defined.
This comment has been removed by the author.
ReplyDeleteMail is not being sent.
ReplyDelete