Advertisement
Guest User

Untitled

a guest
Jul 14th, 2016
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  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 = 'ghapto98@gmail.com';          // SMTP username
  10. $mail->Password = 'anyspeatat11'; // 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('ghapto98@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. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement