Advertisement
Guest User

Untitled

a guest
Jan 25th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.94 KB | None | 0 0
  1.             require '../PHPMailer/PHPMailerAutoload.php';
  2.  
  3.             $mail = new PHPMailer;
  4.  
  5.             //$mail->SMTPDebug = 3;                               // Enable verbose debug output
  6.  
  7.             $mail->isSMTP();                                      // Set mailer to use SMTP
  8.             $mail->Host = 'smtp1.example.com;smtp2.example.com';  // 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 = 587;                                    // TCP port to connect to
  14.  
  15.             $mail->setFrom('from@example.com', 'Mailer');
  16.             $mail->addAddress('joe@example.net', 'Joe User');     // Add a recipient
  17.             $mail->addAddress('ellen@example.com');               // Name is optional
  18.             $mail->addReplyTo('info@example.com', 'Information');
  19.             $mail->addCC('cc@example.com');
  20.             $mail->addBCC('bcc@example.com');
  21.  
  22.             $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
  23.             $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  24.             $mail->isHTML(true);                                  // Set email format to HTML
  25.  
  26.             $mail->Subject = 'Here is the subject';
  27.             $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
  28.             $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  29.  
  30.             if(!$mail->send()) {
  31.                 echo 'Message could not be sent.';
  32.                 echo 'Mailer Error: ' . $mail->ErrorInfo;
  33.             } else {
  34.                 echo 'Message has been sent';
  35.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement