Advertisement
Guest User

Untitled

a guest
Mar 5th, 2019
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. public static function sendMail($subject, $body, $address) {
  2. $mail = new PHPMailer();
  3. $mail->isSMTP();
  4. $mail->SMTPDebug = 2;
  5. $mail->Debugoutput = 'html';
  6. $mail->SMTPAuth = true;
  7. $mail->SMTPSecure = 'tls';
  8. $mail->Host = 'smtp.live.com';
  9. $mail->Port = 587;
  10. $mail->isHTML();
  11. $mail->Username = 'myMail@hotmail.com';
  12. $mail->Password = 'myMailPass';
  13. $mail->SetFrom('no-reply@gmail.com');
  14. $mail->Subject = $subject;
  15. $mail->Body = $body;
  16. $mail->AddAddress($address);
  17. $mail->Send();
  18.  
  19. <?php
  20.  
  21. require 'PHPMailer/PHPMailerAutoload.php';
  22. $mail = new PHPMailer;
  23. $mail->isSMTP();
  24. $mail->Charset = 'utf8_decode()';
  25. $mail->Host = 'smtp.live.com';
  26. $mail->Port = 587;
  27. $mail->SMTPSecure = 'tsl';
  28. $mail->SMTPAuth = true;
  29. $mail->isHTML(true);
  30. $mail->Username = "meuemail@hotmail.com";
  31. $mail->Password = "minhasenha";
  32.  
  33. //Define os destinatário(s)
  34. //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  35. $mail->AddAddress('meuemail@hotmail.com');
  36.  
  37. //Define o remetente
  38. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  39. $mail->AddReplyTo($_POST['email'], utf8_decode($_POST['nome']));
  40. $mail->SetFrom($_POST['email'], utf8_decode($_POST['nome']));
  41.  
  42. $mail->Subject = utf8_decode($_POST['assunto']);
  43. $mail->Body = utf8_decode($_POST['mensagem']);
  44.  
  45. if (!$mail->send()) {
  46. echo "Mailer Error: " . $mail->ErrorInfo;
  47. } else {
  48. echo "<script>javascript:history.back(0)</script>";
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement