Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
870
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.85 KB | None | 0 0
  1. <?php
  2.  
  3. $mail = new PHPMailer(true);                              // Passing `true` enables exceptions
  4. try {
  5.     //Server settings
  6.     $mail->SMTPDebug = 2;                                 // Enable verbose debug output
  7.     //$mail->isSMTP();                                      // Set mailer to use SMTP
  8.     $mail->Host = Configuration::get("mailer_host");  // Specify main and backup SMTP servers
  9.     //$mail->SMTPAuth = true;                               // Enable SMTP authentication
  10.     //$mail->Username = 'user@example.com';                 // SMTP username
  11.     //$mail->Password = 'secret';                           // SMTP password
  12.     //$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  13.     $mail->Port = Configuration::get("mailer_port");                                    // TCP port to connect to
  14.  
  15.     //Recipients
  16.     $mail->setFrom('from@example.com', 'Mailer');
  17.     $mail->addAddress('joe@example.net', 'Joe User');     // Add a recipient
  18.     //mail->addAddress('ellen@example.com');               // Name is optional
  19.     //$mail->addReplyTo('info@example.com', 'Information');
  20.     //$mail->addCC('cc@example.com');
  21.     //$mail->addBCC('bcc@example.com');
  22.  
  23.     //Attachments
  24.     //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
  25.     //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  26.  
  27.     //Content
  28.     $mail->isHTML(true);                                  // Set email format to HTML
  29.     $mail->Subject = 'Here is the subject';
  30.     $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
  31.     $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  32.  
  33.     $mail->send();
  34.     echo 'Message has been sent';
  35. } catch (Exception $e) {
  36.     echo 'Message could not be sent.';
  37.     echo 'Mailer Error: ' . $mail->ErrorInfo;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement