Guest User

Untitled

a guest
Apr 23rd, 2018
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. function sendemail() {
  2.     require_once('[path-to]/class.phpmailer.php');
  3.     $mail = new PHPMailer(true);
  4.     $mail->IsSMTP();
  5.     try {
  6.         $mail->Host = EM_HOST;
  7.         $mail->SMTPDebug = 0; //2 to debug
  8.         $mail->SMTPAuth = EM_AUTH;
  9.         $mail->Username = EM_USER;
  10.         $mail->Password = EM_PASS;
  11.         $mail->AddReplyTo('from@test.com', 'From Name');
  12.         $mail->AddAddress('to@test.com', 'To Name');
  13.         $mail->AddBCC('bcc@test.com', 'BCC Name');
  14.         $mail->SetFrom('from@test.com', 'From Name');
  15.         $mail->Subject = 'Subject String';
  16.         $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
  17.         $body = file_get_contents('[path-to]/emailtemplate.htm');
  18.         $body = eregi_replace("\[fname\]", $_SESSION['fname'], $body);
  19.         $body = eregi_replace("\[sname\]", $_SESSION['sname'], $body);
  20.         $mail->MsgHTML($body);
  21.         $mail->Send();
  22.         @log_this("PDF Sending Success!","email");
  23.     } catch (phpmailerException $e) {
  24.         @log_this("PDF Sending Failed: ".$e->errorMessage(),"email");
  25.     } catch (Exception $e) {
  26.         @log_this("PDF Sending Failed: ".$e->getMessage(),"email");
  27.     }
  28. }
Add Comment
Please, Sign In to add comment