Advertisement
dewiwataru

mailaction.php

Mar 13th, 2019
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2. require 'phpmailer/PHPMailerAutoload.php';
  3.  
  4. $nama_penerima=$_POST['nama'];
  5. $email_penerima=$_POST['email'];
  6. $pesan=$_POST['pesan'];
  7. $subjek="Contoh email - codingan.com";
  8.  
  9. $mail = new PHPMailer(true);
  10.  
  11.  
  12. // memberitahu class untuk menggunakan SMTP
  13. $mail->IsSMTP();
  14.  
  15. // mengaktifkan debug SMTP (untuk pengujian) atur 0 untuk menonaktifkan mode debugging, 1 untuk menampilkan hasil debug
  16. $mail->SMTPDebug = 0;
  17.  
  18. // mengaktifkan otentikasi SMTP
  19. $mail->SMTPAuth = true;
  20.  
  21. // menetapkan prefix ke server
  22. $mail->SMTPSecure = 'ssl';
  23.  
  24. // atur Gmail sebagai server SMTP
  25. $mail->Host = 'smtp.gmail.com';
  26.  
  27. // atur server SMTP untuk server Gmail
  28. $mail->Port = 465;
  29.  
  30.  
  31. $mail->Username = "dewiwataru18@gmail.com";
  32. $mail->Password = "dee_yorozuya";
  33. $webmaster_email = "dewiwataru18@gmail.com";
  34. $email = $email_penerima;
  35. $name = $nama_penerima;
  36. $mail->From= $webmaster_email;
  37. $mail->FromName="Dewi Septiani";
  38. $mail->AddAddress($email, $name);
  39.  
  40. $mail->AddReplyTo($webmaster_email, "Dewi Septiani");
  41. $mail->WordWrap = 50;
  42.  
  43. $mail->IsHTML(true);
  44. $mail->Subject = $subjek;
  45. $mail->Body = $pesan;
  46.  
  47. $mail->AltBody = "";
  48. if(!$mail->Send()) {
  49. echo "mail error" . $mail->ErrorInfo;
  50. } else {
  51. echo "email berhasil di kirim";
  52. }
  53.  
  54.  
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement