Can anyone tell me a step by step tutorial of installing PHPMailer in Yii application?

have a look here

Any other easy tutorial because i could not understand?

  1. download and unzip it

  2. put phpmailer.php, and class.smtp.php in your components folder

  3. use it like this:

$mail = new phpmailer();


$mail->Host = "";

$mail->Username = "";

$mail->Password = "your smtp password";

$mail->SetFrom("", "Full Name");


$mail->Subject = "hello world";

$mail->Body = "buy viagra!";


Okay but where i use above codes?

The codes el chief posted should be posted in an action in your controller.

To Configure PHPmailer with gmail following configuration will do,


$mail = new JPhpMailer;


$mail->SMTPDebug = 1;

$mail->Host = ‘’;

$mail->SMTPAuth = true;

$mail->SMTPSecure = "ssl";

$mail->Username = ‘’;

$mail->Port = ‘465’;

$mail->Password = ‘pwd’;

$mail->SetFrom(‘’, ‘name’);

$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(‘JUST A TEST!’);

$mail->AddAddress(‘’, ‘name’);


In my case it was a lack of SSL support in PHP which gave this error.

So I enabled extension=php_openssl.dll

$mail->SMTPDebug = 1; also hinted towards this solution.

Since this is one of your first posts, you are not allowed to embed links in your post.

Below is the content of your post:

Though the bug is solved but I would like to inform by this post that JPhpMailer uses Famous PHP Mailer phpmailer(dot) worxware(dot)com/

Always try to use the latest version from the authors site.

I was having an issue with PHP mailer where I was trying to send files in Attachment.

The issue was the File was sent as base64 Encoded Encryption(When the Extension was used in Linux Centos Server) and surprisingly it was working fine when the same code was written in a windows hosted machine.

The Version with issues was 5.1 and the proper working version was 5.2.8 (Version mentioned are of PHP mailer)

Hope this post may help anyone facing the issue. Can let me know if I can help anyone for the same.