daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Sep 26th, 2016 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require 'PHPMailer/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 = 'Email Address';          // SMTP username
  10. $mail->Password = 'Email Account 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('info@codexworld.com', 'CodexWorld');
  15. $mail->addReplyTo('info@codexworld.com', 'CodexWorld');
  16. $mail->addAddress('john@gmail.com');   // Add a recipient
  17. $mail->addCC('cc@example.com');
  18. $mail->addBCC('bcc@example.com');
  19.  
  20. $mail->isHTML(true);  // Set email format to HTML
  21.  
  22. $bodyContent = '<h1>How to Send Email using PHP in Localhost by CodexWorld</h1>';
  23. $bodyContent .= '<p>This is the HTML email sent from localhost using    PHP script by <b>CodexWorld</b></p>';
  24.  
  25. $mail->Subject = 'Email from Localhost by CodexWorld';
  26. $mail->Body    = $bodyContent;
  27.  
  28. if(!$mail->send()) {
  29.    echo 'Message could not be sent.';
  30.    echo 'Mailer Error: ' . $mail->ErrorInfo;
  31.  } else {
  32.   echo 'Message has been sent';
  33. }
  34. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top