Advertisement
Guest User

Untitled

a guest
Oct 5th, 2016
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * This example shows settings to use when sending via Google's Gmail servers.
  5. */
  6. //SMTP needs accurate times, and the PHP time zone MUST be set
  7. //This should be done in your php.ini, but this is how to do it if you don't have access to that
  8. date_default_timezone_set('Etc/UTC');
  9. require 'PHPMailerAutoload.php';
  10. //Create a new PHPMailer instance
  11. $mail = new PHPMailer;
  12. //Tell PHPMailer to use SMTP
  13. $mail->isSMTP();
  14. //Enable SMTP debugging
  15. // 0 = off (for production use)
  16. // 1 = client messages
  17. // 2 = client and server messages
  18. $mail->SMTPDebug = 2;
  19. //Ask for HTML-friendly debug output
  20. $mail->Debugoutput = 'html';
  21. //Set the hostname of the mail server
  22. $mail->Host = 'smtp.gmail.com';
  23. // use
  24. // $mail->Host = gethostbyname('smtp.gmail.com');
  25. // if your network does not support SMTP over IPv6
  26. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  27. $mail->Port = 587;
  28. //Set the encryption system to use - ssl (deprecated) or tls
  29. $mail->SMTPSecure = 'tls';
  30. //Whether to use SMTP authentication
  31. $mail->SMTPAuth = true;
  32. //Username to use for SMTP authentication - use full email address for gmail
  33. $mail->Username = "mailsemillas@gmail.com";
  34. //Password to use for SMTP authentication
  35. $mail->Password = "agente2016";
  36. //Set who the message is to be sent from
  37. $mail->setFrom('from@example.com', 'First Last');
  38. //Set an alternative reply-to address
  39. $mail->addReplyTo('oguisk@hotmail.com', 'First Last');
  40. //Set who the message is to be sent to
  41. $mail->addAddress('oguisk@hotmail.com', 'John Doe');
  42. //Set the subject line
  43. $mail->Subject = 'PHPMailer GMail SMTP test';
  44. //Read an HTML message body from an external file, convert referenced images to embedded,
  45. //convert HTML into a basic plain-text alternative body
  46. $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  47. //Replace the plain text body with one created manually
  48. $mail->AltBody = 'This is a plain-text message body';
  49. //Attach an image file
  50. //$mail->addAttachment('images/phpmailer_mini.png');
  51. //send the message, check for errors
  52. if (!$mail->send()) {
  53. echo "Mailer Error: " . $mail->ErrorInfo;
  54. } else {
  55. echo "Message sent!";
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement