Guest User

Untitled

a guest
Sep 25th, 2016
2,227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.86 KB | None | 0 0
  1. public static function sendTestEmail(){
  2.         $mail = new PHPMailer;
  3.         //$mail->SMTPDebug = 3;                               // Enable verbose debug output
  4.         $mail->isSMTP();                                      // Set mailer to use SMTP
  5.         $mail->SMTPOptions = array(
  6.             'ssl' => array(
  7.                 'verify_peer' => false,
  8.                 'verify_peer_name' => false,
  9.                 'allow_self_signed' => true
  10.             )
  11.         );
  12.         $mail->SMTPAuth = true;                               // Enable SMTP authentication
  13.         //$mail->SMTPDebug=2;
  14.  
  15.         $mail->Host = 'mail.pgpriorcargo.com';  // Specify main and backup SMTP servers
  16.         $mail->Username = '[email protected]';                 // SMTP username
  17.         $mail->Password = '1q2w3e4r5t';                           // SMTP password
  18.         //$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  19.         $mail->Port = 587;                                    // TCP port to connect to
  20.         $mail->setFrom('[email protected]', 'PGPriorCargo Webmaster');
  21.         $mail->AddReplyTo('[email protected]', 'PGPriorCargo Webmaster');
  22.         $mail->Subject = 'Priorcargo pending materials';
  23.         $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!";
  24.         $mail->isHTML(true);
  25.         /*$headers = "MIME-Version: 1.0" . "\r\n";
  26.         $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
  27.         $headers .= "From: [email protected]" . "\r\n" .
  28.             "Reply-To: [email protected]" . "\r\n" .
  29.             "X-Mailer: PHP/" . phpversion();
  30.         $mail->addCustomHeader($headers);*/
  31.         $template=file_get_contents(Config::PATH."/views/emailtemplates/test.html");
  32.         //$mail->addAddress("[email protected]", "Veeru PV");
  33.         $mail->addAddress("[email protected]", "Veeru PV");
  34.         $mail->addAddress("[email protected]", "Veeru PV");
  35.         $mail->addAddress("[email protected]", "Veeru PV");
  36.         $mail->addAddress("[email protected]", "Veeru PV");
  37.         $mail->addAddress("[email protected]", "Veeru PV");
  38.         $mail->addAddress("[email protected]", "Veeru PV");
  39.         $mail->MsgHTML($template);
  40.         //$mail->Body=$template;
  41.         $response=array();
  42.         if(!$mail->send()){
  43.             $response["status"]=0;
  44.             $response["message"]="Error sending email";
  45.         }else{
  46.             $response["status"]=1;
  47.             $response["message"]="Email sent";
  48.  
  49.         }
  50.         echo json_encode($response);
  51.        
  52.     }
Advertisement
Add Comment
Please, Sign In to add comment