Advertisement
Guest User

Untitled

a guest
Apr 14th, 2017
1,288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.92 KB | None | 0 0
  1. <?php
  2. /**
  3.  * This example shows making an SMTP connection with authentication.
  4.  */
  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.  
  10. require '../PHPMailerAutoload.php';
  11.  
  12. //Create a new PHPMailer instance
  13. $mail = new PHPMailer;
  14. //Tell PHPMailer to use SMTP
  15. $mail->isSMTP();
  16. //Enable SMTP debugging
  17. // 0 = off (for production use)
  18. // 1 = client messages
  19. // 2 = client and server messages
  20. $mail->SMTPDebug = 2;
  21. //Ask for HTML-friendly debug output
  22. $mail->Debugoutput = 'html';
  23. //Set the hostname of the mail server
  24. $mail->Host = "in-v3.mailjet.com";
  25. //Set the SMTP port number - likely to be 25, 465 or 587
  26. $mail->Port = 25;
  27. //Whether to use SMTP authentication
  28. $mail->SMTPAuth = true;
  29. //Username to use for SMTP authentication
  30. $mail->Username = "51d8de94f0c1cac9259fa95867ab7eaa";
  31. //Password to use for SMTP authentication
  32. $mail->Password = "22dee9579e5d88c082f5f1204d5b8c65";
  33. //Set who the message is to be sent from
  34. $mail->setFrom('contact@obk-shop.com', 'First Last');
  35. //Set an alternative reply-to address
  36. $mail->addReplyTo('replyto@example.com', 'First Last');
  37. //Set who the message is to be sent to
  38. $mail->addAddress('mrpandas@hotmail.fr', 'John Doe');
  39. //Set the subject line
  40. $mail->Subject = 'PHPMailer SMTP test';
  41. //Read an HTML message body from an external file, convert referenced images to embedded,
  42. //convert HTML into a basic plain-text alternative body
  43. $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  44. //Replace the plain text body with one created manually
  45. $mail->AltBody = 'This is a plain-text message body';
  46. //Attach an image file
  47. $mail->addAttachment('images/phpmailer_mini.png');
  48.  
  49. //send the message, check for errors
  50. if (!$mail->send()) {
  51.     echo "Mailer Error: " . $mail->ErrorInfo;
  52. } else {
  53.     echo "Message sent!";
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement