Advertisement
Guest User

Untitled

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