Advertisement
Guest User

Untitled

a guest
Sep 4th, 2016
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2. require 'mailer/PHPMailerAutoload.php';
  3.  
  4. $mail = new PHPMailer;
  5.  
  6. $mail->isSMTP(); // Set mailer to use SMTP
  7. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  8. $mail->SMTPAuth = true; // Enable SMTP authentication
  9. $mail->Username = '<my-email>@gmail.com'; // SMTP username
  10. $mail->Password = '<password>'; // SMTP password
  11. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  12. $mail->Port = 587; // TCP port to connect to
  13.  
  14. $mail->setFrom('<my-email>@gmail.com', 'abhishek');
  15. $mail->addAddress('<mob-no>@bplmobile.com'); // Add a recipient
  16.  
  17. $mail->isHTML(true); // Set email format to HTML
  18.  
  19. $bodyContent = 'Hello world';
  20. $mail->Subject = 'Demo Subject';
  21. $mail->Body = $bodyContent;
  22.  
  23. if(!$mail->send()) {
  24. echo 'Message could not be sent.';
  25. echo 'Mailer Error: ' . $mail->ErrorInfo;
  26. } else {
  27. echo 'Message has been sent';
  28. }
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement