Advertisement
ali_siddique

Email Function With smtp

Sep 19th, 2013
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. <?php
  2.  
  3. $name= $_REQUEST['name'] ;
  4. $email= $_REQUEST['email'] ;
  5. $comments= $_REQUEST['comments'] ;
  6.  
  7. require("/home/uparw/public_html/demo6/14/PHPMailer-master/class.phpmailer.php");
  8.  
  9. $mail = new PHPMailer;
  10.  
  11. // For Useing Domian mail
  12. $mail->isSMTP(); // Set mailer to use SMTP
  13. $mail->SMTPDebug = 0;
  14. $mail->Host = 'localhost'; // Specify main and backup server
  15. $mail->SMTPAuth = true; // Enable SMTP authentication
  16. $mail->Username = 'ali@uparw.com'; // SMTP username
  17. $mail->Password = 'password'; // SMTP password
  18. $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
  19.  
  20. // For Gmail
  21. //$mail->SMTPAuth = true; // authentication enabled
  22. //$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
  23. //$mail->Host = "smtp.gmail.com";
  24. //$mail->Port = 465; // or 587
  25. //$mail->IsHTML(true);
  26. //$mail->Username = "aliuparrow@gmail.com";
  27. //$mail->Password = "password";
  28.  
  29.  
  30. $mail->From = 'ali@uparw.com';
  31. $mail->FromName = $name;
  32. $mail->addAddress('alisiddique2011@gmail.com', 'Ali Siddique'); // Add a recipient
  33. //$mail->addAddress('alisiddique2011@gmail.com'); // Name is optional
  34. //$mail->addReplyTo('alisiddique2011@gmail.com', 'Ali');
  35. //$mail->addCC('cc@example.com');
  36. //$mail->addBCC('bcc@example.com');
  37.  
  38. //$mail->WordWrap = 50; // Set word wrap to 50 characters
  39. //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  40. //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  41. $mail->isHTML(true); // Set email format to HTML
  42.  
  43. $mail->Subject = 'Query From healthjourney ';
  44. $mail->Body = 'Email: ' . $email . '<br />' . 'Comment: ' . $comments;
  45. $mail->AltBody = 'Email: ' . $email . '<br />' . 'Comment: ' . $comments;
  46.  
  47. //if(!$mail->send()) {
  48. //echo 'Message could not be sent.';
  49. //echo 'Mailer Error: ' . $mail->ErrorInfo;
  50. // exit;
  51. //}
  52. $output = '';
  53. if(!$mail->Send())
  54. {
  55. $output .= "Mailer Error: ". $mail->ErrorInfo;
  56. }
  57. else
  58. {
  59. ob_clean();
  60. header('Location: thankyou.html');
  61. exit();
  62. }
  63. echo $output;
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement