Advertisement
Guest User

Untitled

a guest
Feb 11th, 2019
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. if(isset($_POST['send'])){
  2.  
  3. $mail = new PHPMailer(true); // Passing `true` enables exceptions
  4. try {
  5.  
  6. $dataemail = $_POST['email'];
  7. $datasubject = $_POST['subject'];
  8. $datadeskripsi = $_POST['deskripsi'];
  9.  
  10. $query = mysqli_query($link,"INSERT INTO mailer (email,subject,deskripsi)VALUES('$dataemail','$datasubject','$datadeskripsi')");
  11.  
  12. if($query){
  13. echo "sukses";
  14. }
  15. else {
  16. echo "gagal";
  17. }
  18.  
  19.  
  20.  
  21.  
  22. $emailTo = $_POST['email'];
  23. $subject = $_POST['subject'];
  24. $deskripsi = $_POST['deskripsi'];
  25.  
  26. //Server settings
  27. $mail->SMTPDebug = 0; // Enable verbose debug output
  28. $mail->isSMTP(); // Set mailer to use SMTP
  29. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  30. $mail->SMTPAuth = true; // Enable SMTP authentication
  31. $mail->Username = SMTPUSER; // SMTP username
  32. $mail->Password = SMTPPASS; // SMTP password
  33. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  34. $mail->Port = 587; // TCP port to connect to
  35.  
  36. //Recipients
  37. $mail->setFrom('adirahman.id@gmail.com', 'adi rahman');
  38. $mail->addAddress($emailTo); // Add a recipient
  39. //Content
  40. $mail->isHTML(true); // Set email format to HTML
  41. $mail->Subject = $subject;
  42. $mail->Body = $deskripsi;
  43.  
  44. $mail->send();
  45. echo 'Message has been sent';
  46. } catch (Exception $e) {
  47. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  48. }
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement