Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <?php
  2. function mail() {
  3. $mail = new PHPMailer;
  4.  
  5. $mail->isSMTP();
  6. //Enable SMTP debugging
  7. // 0 = off (for production use)
  8. // 1 = client messages
  9. // 2 = client and server messages
  10. $mail->SMTPDebug = 2;
  11. //Ask for HTML-friendly debug output
  12. $mail->Debugoutput = 'html';
  13. //Set the hostname of the mail server
  14. $mail->Host = 'smtp.gmail.com';
  15. // use
  16. // $mail->Host = gethostbyname('smtp.gmail.com');
  17. // if your network does not support SMTP over IPv6
  18. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  19. $mail->Port = 587;
  20. //Set the encryption system to use - ssl (deprecated) or tls
  21. $mail->SMTPSecure = 'tls';
  22. //Whether to use SMTP authentication
  23. $mail->SMTPAuth = true;
  24. //Username to use for SMTP authentication - use full email address for gmail
  25. $mail->Username = "X69XhelloworldX69X@gmail.com";
  26. //Password to use for SMTP authentication
  27. $mail->Password = "helloworld123";
  28. //Set who the message is to be sent from
  29. $mail->setFrom('X69XhelloworldX69X@gmail.com', "Jopje's Knopje");
  30. //Set an alternative reply-to address
  31. // $mail->addReplyTo('jboeve009@gmail.com');
  32. //Set who the message is to be sent to
  33. $mail->addAddress('jboeve009@gmail.com');
  34. //Set the subject line
  35. $mail->Subject = 'PHPMailer GMail SMTP test';
  36. //Read an HTML message body from an external file, convert referenced images to embedded,
  37. //convert HTML into a basic plain-text alternative body
  38. $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  39. //Replace the plain text body with one created manually
  40. $mail->AltBody = 'This is a plain-text message body';
  41. //send the message, check for errors
  42. if (!$mail->send()) {
  43. echo "Mailer Error: " . $mail->ErrorInfo;
  44. } else {
  45. echo "Message sent!";
  46. }
  47. }
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement