Guest User

Untitled

a guest
Dec 10th, 2017
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. <?php
  2. sendMail("tosomeid@gmail.com", "fromsomeid@gmail.com", "test", "test msg<br>hello!");
  3.  
  4. function sendMail($to, $from, $subject, $message) {
  5. try {
  6. //$to='tosomeid@gmail.com';
  7. $headers = "MIME-Version: 1.0" . "rn";
  8. $headers .= "Content-type:text/html;charset=iso-8859-1" . "rn";
  9. $headers .= 'From:' . $from . ' <fromsomeid@gmail.com>' . "rn";
  10. ini_set("sendmail_from", "fromsomeid@gmail.com");
  11. require_once("class.phpmailer.php");
  12. require_once("class.smtp.php");
  13. set_time_limit(240);
  14. $mail = new PHPMailer(true);
  15. $mail->IsSMTP(); // telling the class to use SMTP
  16. $mail->SMTPAutoTLS = false;
  17. $mail->Host = "smtp.gmail.com";
  18. $mail->SMTPDebug = 4;
  19. $mail->SMTPAuth = true; // enable SMTP authentication
  20. $mail->Port = 587; // or 587 // set the SMTP port for the GMAIL server
  21. $mail->Username = "fromsomeid@gmail.com"; // SMTP account username
  22. $mail->Password = "password123"; // SMTP account password
  23. $mail->From = "fromsomeid@gmail.com";
  24. $mail->SMTPSecure = 'tls';
  25.  
  26. $mail->AddAddress("tosomeid@gmail.com");
  27. $mail->SetFrom('fromsomeid@gmail.com', $from);
  28. $mail->AddReplyTo("fromsomeid@gmail.com", $from);
  29. $mail->AddBCC("tosomeid@gmail.com");
  30. $mail->IsHTML(true);
  31. $mail->Subject = $subject;
  32. $mail->Body = $message;
  33. $mail->WordWrap = 50;
  34. echo 'sendMail to=>' . $to;
  35. if (!$mail->Send()) {
  36. echo 'Message was not sent.';
  37. echo 'Mailer error: ' . $mail->ErrorInfo;
  38. } else {
  39. echo '<br>Message was sent successfully to selected recipients.';
  40. }
  41. } catch (Exception $ex) {
  42.  
  43. echo'EXCEPTION <br>';
  44. echo '<br>Caught exception: ' . $ex->getMessage() . "n".$ex->getTraceAsString();
  45. }
  46. }
  47.  
  48. ?>
Add Comment
Please, Sign In to add comment