How to send email by using phpmailer

php

Posted on 13 Feb 15 by Vickey
  445



First Download phpmailer.zip and extract it now include it in your file

require_once(APP_ROOT_PATH.'/PHPMailer/class.phpmailer.php');

now create a function

 function sendEmail($receiptEmail,$senderEmail,$cc,$subject,$message)
     //function sendEmail($receiptName, $receiptEmail, $subject, $message, $senderEmail='test@gmail.com', $senderName='test')
    { 
    $subject = utf8_decode($subject);
    $senderName='Welcome';
      $mail = new PHPMailer();
      $mail->IsSMTP(); 
      $mail->SMTPAuth   = true; 
      $mail->SMTPSecure = "ssl";  
      $mail->Host       = "smtp.gmail.com"; 
      $mail->Port       = 465;                
      $mail->Username   = "example@gmail.com";
      $mail->Password   = "example@12345";            
      $mail->SetFrom("$senderEmail", "$senderName"); 
      $mail->Subject    = $subject; 
      $mail->Body       = $message;
      $mail->IsHTML(true);
      $mail->AddAddress($receiptEmail, $receiptName);
      return $mail->Send();
    }

and now you call it where you want to send email


If this post help you reduce time to develop, you can help me to maintain this website :)
www.000webhost.com