Download the extension and add it into protected/extension folder. Now configure the smtp details in protected/config/main.php
'components'=>array( 'Smtpmail'=>array( 'class'=>'application.extensions.smtpmail.PHPMailer', 'Host'=>"mail.yourdomain.com", 'Username'=>'test@yourdomain.com', 'Password'=>'test', 'Mailer'=>'smtp', 'Port'=>26, 'SMTPAuth'=>true, ), ),
public function mailsend($to,$from,$subject,$message){ $mail=Yii::app()->Smtpmail; $mail->SetFrom($from, 'From NAme'); $mail->Subject = $subject; $mail->MsgHTML($message); $mail->AddAddress($to, ""); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; }else { echo "Message sent!"; } }
Total 3 comments
can anyone please tell me how to attach pdf file using this extension?
Just configure like this in your config/main
And Don't forget to activate your php_openssl in PHP.ini
If you know How to handle mail using Gmail host, Please post here
Leave a comment
Please login to leave your comment.