vijayrami

sendmail.php

Jan 4th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. sendmail.php
  2. https://github.com/PHPMailer/PHPMailer
  3. <?php
  4. require_once('../PHPMailer/PHPMailerAutoload.php');
  5.  
  6. $mail = new PHPMailer;
  7.  
  8. //$mail->SMTPDebug = 3;// debugging: 1 = errors and messages, 2 = messages only                               // Enable verbose debug output
  9.  
  10. $mail->isSMTP();                                      // Set mailer to use SMTP
  11. $mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
  12. $mail->SMTPAuth = true;                               // Enable SMTP authentication
  13. $mail->Username = '[email protected]';                 // SMTP username
  14. $mail->Password = '*************';                           // SMTP password
  15. $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail  // Enable TLS encryption, `ssl` also accepted
  16. $mail->Port = 465;           // or 587                         // TCP port to connect to
  17.  
  18. $mail->setFrom('[email protected]', 'Vijay Rami');
  19. $mail->addAddress('[email protected]', 'Vijay Rami');     // Add a recipient
  20. //$mail->addAddress('[email protected]');               // Name is optional
  21. //$mail->addReplyTo('[email protected]', 'Information');
  22. //$mail->addCC('[email protected]');
  23. //$mail->addBCC('[email protected]');
  24.  
  25. //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
  26. //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  27. //$mail->isHTML(true);                                  // Set email format to HTML
  28.  
  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. if(!$mail->send()) {
  34.     echo 'Message could not be sent.';
  35.     echo 'Mailer Error: ' . $mail->ErrorInfo;
  36. } else {
  37.     echo 'Message has been sent';
  38. }
Add Comment
Please, Sign In to add comment