Guest User

Untitled

a guest
Dec 8th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. function smtpmailer($to, $from, $from_name, $subject, $body) {
  2.         global $error;
  3.         $mail = new PHPMailer();  // create a new object
  4.         $mail->IsSMTP(); // enable SMTP
  5.         $mail->SMTPDebug = 0;  // debugging: 1 = errors and messages, 2 = messages only
  6.         $mail->SMTPAuth = true;  // authentication enabled
  7.         $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
  8.         $mail->Host = 'smtp.gmail.com';
  9.         $mail->Port = 465;
  10.         $mail->Username = 'status@compasslabs.com';  
  11.         $mail->Password = 'status';          
  12.         $mail->SetFrom($from, $from_name);
  13.         $mail->Subject = $subject;
  14.         $mail->Body = $body;
  15.         foreach ($to as $a)
  16.                 $mail->AddAddress($a);
  17.         if(!$mail->Send()) {
  18.                 $error = 'Mail error: '.$mail->ErrorInfo;
  19.                 echo "Error Sending mail \n";
  20.                 print_r($error);
  21.                 return false;
  22.         } else {
  23.                 $error = 'Message sent!';
  24.                 echo 'Message Sent' . "\n";
  25.                 return true;
  26.         }
  27. }
Add Comment
Please, Sign In to add comment