smtp-mail

I created one SMTP mail extension using phpmailer class
6 followers

Add the SMTP Details in main.php

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, 
        ),
),

Create Mailfunction

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

#13643 report it
priyanka06 at 2013/06/13 08:06am
regarding file attachment

can anyone please tell me how to attach pdf file using this extension?

#13154 report it
reptildarat at 2013/05/08 09:47pm
Gmail Configuration

Just configure like this in your config/main

'Smtpmail'=>array(
            'class'=>'application.extensions.smtpmail.PHPMailer',
            'Host'=>"smtp.gmail.com",
            'Username'=>'your@gmail.com',
            'Password'=>'password here',
            'Mailer'=>'smtp',
            'Port'=>587,
            'SMTPAuth'=>true,
            'SMTPSecure' => 'tls',
        ),

And Don't forget to activate your php_openssl in PHP.ini

#12309 report it
mbala at 2013/03/13 03:03am
Gmail

If you know How to handle mail using Gmail host, Please post here

Leave a comment

Please to leave your comment.

Create extension
Downloads