Guest User

Untitled

a guest
Nov 15th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. <?php
  2.  
  3. // please only use the fields thata re present in the html form itself for now we have listed all possible ones
  4.  
  5. //// NEW CODE ////
  6. require '../mail/PHPMailerAutoload.php';
  7.  
  8.  
  9. $mail = new PHPMailer;
  10.  
  11. //$mail->SMTPDebug = 3; // Enable verbose debug output
  12.  
  13. $mail->isSMTP(); // Set mailer to use SMTP
  14. $mail->Host = 'smtp.domain.com'; // Specify main and backup SMTP servers
  15. $mail->SMTPAuth = true; // Enable SMTP authentication
  16. $mail->Username = 'username'; // SMTP username
  17. $mail->Password = 'password'; // SMTP password
  18. $mail->SMTPSecure = 'SSL'; // Enable TLS encryption, `ssl` also accepted
  19. $mail->Port = 465; // TCP port to connect to
  20.  
  21. $mail->SMTPOptions = array(
  22. 'ssl' => array(
  23. 'verify_peer' => false,
  24. 'verify_peer_name' => false,
  25. 'allow_self_signed' => true
  26. )
  27. );
  28.  
  29. $mail->setFrom('hello@example.com', 'Name');
  30. $mail->addAddress('maher@domain.com', 'Location'); // Add a recipient // Name is optional
  31. $mail->addReplyTo('hello@example.com', 'Name');
  32. //$mail->addCC('cc@example.com');
  33. //$mail->addBCC('bcc@example.com');
  34.  
  35. //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  36. //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  37. $mail->isHTML(true); // Set email format to HTML
  38.  
  39. $mail->Subject = 'Here is the subject';
  40. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  41. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  42.  
  43. if(!$mail->send()) {
  44. echo 'Message could not be sent.';
  45. echo 'Mailer Error: ' . $mail->ErrorInfo;
  46. } else {
  47. echo 'Message has been sent';
  48. }
  49.  
  50. //// OLD CODE ////
  51.  
  52. $to = "maher@domain.com";
  53. if (isset($_POST)){
  54.  
  55. $subject = "location system email";
  56.  
  57. if ($_POST['fullname'] ! =''){
  58. $message = "Fullname: " . $_POST['fullname'];
  59. } else {
  60. $message = "First name: " . $_POST['fname'];
  61. $message = "Last name: " . $_POST['lname'];
  62. }
  63. $message .= "<br>Phone: " . $_POST['Phone'];
  64. $message .= "<br>Website: " . $_POST['website'];
  65. $message .= "<br>Email: " . $_POST['email'];
  66. $message .= "<br>Message: " . $_POST['message'];
  67.  
  68. };
  69.  
  70. $headers = "MIME-Version: 1.0" . "rn";
  71. $headers .= "Content-type: text/html; charset=utf-8" . "rn";
  72. $headers .= "From: " . $_POST['fullname'] . " <" . $_POST['email'] . ">". "rn";
  73.  
  74. if(mail($to, $subject, $message, $headers) ) {
  75. echo "ok";
  76. } else {
  77. echo "error";
  78. }
Add Comment
Please, Sign In to add comment