PHP email transport class featuring file attachments, SMTP servers, CCs, BCCs, HTML messages, word wrap, and more. Sends email via sendmail, PHP mail(), QMail, or with SMTP. New PHPMailer for PHP5 released!!
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
protected/extensions
Usage ¶
See the following code example:
Yii::import('application.extensions.phpmailer.JPhpMailer');
$mail = new JPhpMailer;
$mail->IsSMTP();
$mail->Host = 'smpt.163.com';
$mail->SMTPAuth = true;
$mail->Username = 'yourname@163.com';
$mail->Password = 'yourpassword';
$mail->SetFrom('yourname@163.com', 'yourname');
$mail->Subject = 'PHPMailer Test Subject via smtp, basic with authentication';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML('<h1>JUST A TEST!</h1>');
$mail->AddAddress('john.doe@otherdomain.com', 'John Doe');
$mail->Send();
Change Log ¶
January 22, 2010 ¶
- Initial release.
good email
It works good!
but if use it as components you must edit it.
such as:
add init();
add reply-to email;
change the iso-8859-1 to utf-8 for subject is not show in chinese.
Only ....
Suppose smtp require SSL auth,
such smtp as smtm.gmail.com ?
What than ?
Great
Works great!
Thanx a lot
Congratulations
It works for me. Thank you for the extension.
How is this better than just using the raw php file?
I can put phpmailer.php in my components folder and call $mail = new phpmailer();
why bother with the extension?
Support
VIEW / THEME supports?
reply to prchakal
renderPartial() in your controller is simple~
Gmail Testing fail
I am using Gmail also, but I fail to send email. Below is the snippet
$mail = new JPhpMailer; $mail->IsSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->Port = '465'; $mail->SMTPSecure = 'SSL'; $mail->SMTPAuth = true; $mail->Username = 'mygmail@gmail.com'; $mail->Password = 'password'; $mail->SetFrom('mygmail@gmail.com', 'Falcon'); $mail->Subject = 'Welcome to Hazel Eyes'; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; $mail->MsgHTML('<h1>JUST A TEST!</h1>'); $mail->AddAddress('myother@hotmail.com', 'Falcon CK'); $mail->Send();
Confusion
Thanks for the simple extension.
I had a bit of problem with the Gmail SMTP connection, but eventually found that adding the following solved the problem.
$mail->SMTPSecure = "ssl";
When I click submit on the default contact page form, the flash message tells my the email has been sent. This happens on localhost and the live test server. I am not sure why the code is executing correctly but no emails are arriving. (And yes, the email addresses and passwords were all correct and valid :)
I have the following code in my controller, please take a look and tell me if I'm missing something.
Thanks
public function actionContact() { $model=new ContactForm; if(isset($_POST['ContactForm'])) { $model->attributes=$_POST['ContactForm']; if($model->validate()) { Yii::import('application.extensions.phpmailer.JPhpMailer'); $mail = new JPhpMailer; $mail->IsSMTP(); $mail->SMTPSecure = "ssl"; $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->SMTPSecure = true; $mail->Username = 'myusername@gmail.com'; $mail->Port = '465'; $mail->Password = '******'; $mail->SMTPKeepAlive = true; $mail->Mailer = "smtp"; $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; $mail->CharSet = 'utf-8'; $mail->SMTPDebug = 0; $mail->SetFrom('myusername@gmail.com', 'myname'); $mail->Subject = 'PHPMailer Test Subject via GMail, basic with authentication'; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; $mail->MsgHTML('<h1>JUST A TEST!</h1>'); $mail->AddAddress('to@someone.co.za', 'John Doe'); $mail->Send(); Yii::app()->user->setFlash('contact','Thank you for... as possible.'); $this->refresh(); } } $this->render('contact',array('model'=>$model)); }
Thank you!
Thank you for adding this as an extension. Works fantastic after tons of trouble with two other mailers.
Thanks again.
GoogleMail
Not sure if it already works for you, but if you want to connect to a google mail account you have to set up the host like this:
$mail->Host = 'smtp.googlemail.com:465'; $mail->SMTPSecure = "ssl";
Smtp Error: Could Not Connect To Smtp Host
i am getting the error => Smtp Error: Could Not Connect To Smtp Host
can any one tell how to fix it thnx... :)
Cool
Working great.
Thank you for the extension.
Doesn't work in console mode.
Have any idea why ? In web version everything is fine, but in console mode is not.
When I try to use $mailer->Send() it start thinking about a minute, after that script dies. It doesn't show me any errors or something else.
Thing is that the same code sends mail in web mode, but doesn't in console.(all params are the same at console and at web apps).
Here is my code:
$email = Yii::app()->mailer; $email->ClearAddresses(); $email->ContentType = 'text/html'; $email->From = Yii::app()->params['noReplyEmail']; $email->FromName = Yii::app()->params['noReplyTitle']; $email->AddAddress('test@gmail.com'); $email->Subject = 'my subject'; $email->Body = 'Hello!'; $email->Send(); $email->ClearAllRecipients();
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.