Advertisement
Guest User

Untitled

a guest
Oct 29th, 2013
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. PHP Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto in /usr/share/php5/class.smtp.php on line 274
  2.  
  3. <?php
  4. require_once('class.phpmailer.php');
  5. include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  6. $mail = new PHPMailer();
  7.  
  8. $body = file_get_contents('contents.html');
  9. $body = eregi_replace("[]",'',$body);
  10.  
  11. $mail->IsSMTP(); // telling the class to use SMTP
  12. $mail->Host = "mail.yourdomain.com"; // SMTP server
  13. $mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
  14. // 1 = errors and messages
  15. // 2 = messages only
  16. $mail->SMTPAuth = true; // enable SMTP authentication
  17. $mail->SMTPSecure = "tls"; // sets the prefix to the servier
  18. $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
  19. $mail->Port = 587; // set the SMTP port for the GMAIL server
  20. $mail->Username = "my email address"; // GMAIL username
  21. $mail->Password = "my password"; // GMAIL password
  22.  
  23. $mail->SetFrom('name@yourdomain.com', 'First Last');
  24.  
  25. $mail->AddReplyTo("name@yourdomain.com","First Last");
  26.  
  27. $mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic";
  28.  
  29. $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  30.  
  31. $mail->MsgHTML($body);
  32. $address = "whoto@otherdomain.com";
  33. $mail->AddAddress($address, "John Doe");
  34.  
  35. if(!$mail->Send()) {
  36. echo "Mailer Error: " . $mail->ErrorInfo;
  37. } else {
  38. echo "Message sent!";
  39. }
  40.  
  41. ?>
  42.  
  43. <html>
  44. <head>
  45. <title>PHPMailer - SMTP basic test with authentication</title>
  46. </head>
  47. <body>
  48.  
  49. <?php
  50.  
  51.  
  52. error_reporting(E_STRICT);
  53.  
  54. date_default_timezone_set('America/Toronto');
  55.  
  56. require_once('class.phpmailer.php');
  57. //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  58.  
  59. $mail = new PHPMailer(); // create a new object
  60. $mail->IsSMTP(); // enable SMTP
  61. $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
  62. $mail->SMTPAuth = true; // authentication enabled
  63. $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
  64. $mail->Host = "smtp.gmail.com";
  65. $mail->Port = 465; // or 587
  66. $mail->IsHTML(true);
  67. $mail->Username = "***";
  68. $mail->Password = "***";
  69. $mail->SetFrom("dad");
  70. $mail->Subject = "Test";
  71. $mail->Body = "hello";
  72. $mail->AddAddress("janakprajapati90@gmail.com");
  73. if(!$mail->Send())
  74. {
  75. echo "Mailer Error: " . $mail->ErrorInfo;
  76. }
  77. else
  78. {
  79. echo "Message has been sent";
  80. }
  81.  
  82. ?>
  83.  
  84. </body>
  85. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement