Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. class.phpmailer.php
  2. class.smtp.php
  3. index.php
  4. web.config
  5.  
  6. <Center><h2>PHP Test Email Script</h2></center>
  7. <?php
  8. // display form if user has not clicked submit
  9. if (!isset($_POST["submit"])) {
  10. ?>
  11. <form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>" target="_blank">
  12. <Table align = center>
  13.  
  14. <tr><td>From Email: <td><input type="text" name="uname"> i.e yourname@yourdomain.com</tr>
  15. <tr><td>Email Password: <td><input type="password" name="pass"></tr>
  16. <tr><td>Host: <td><input type="text" name="host"> i.e Mail.YourDomain.com</tr>
  17. <tr><td>To:<td> <input type="text" name="to"></tr>
  18.  
  19. <tr><td colspan =2 align = center><input type="submit" name="submit" value="Send Email"></tr>
  20. </table>
  21. </form>
  22.  
  23. <?php
  24. }
  25. else { // the user has submitted the form
  26.  
  27. include("class.phpmailer.php"); //you have to upload class files "class.phpmailer.php" and "class.smtp.php"
  28.  
  29. $mail = new PHPMailer();
  30.  
  31. $mail->IsSMTP();
  32. $mail->SMTPAuth = true;
  33.  
  34. $mail->Host = $_POST["host"];
  35.  
  36. $mail->Username = $_POST["uname"];
  37. $mail->Password = $_POST["pass"];
  38.  
  39. $mail->From = $_POST["uname"];
  40. $mail->FromName = "demouser";
  41.  
  42. $mail->AddAddress($_POST["to"],"test");
  43. $mail->Subject = "This is the subject";
  44. $mail->Body = "This is a sample message using SMTP authentication";
  45. $mail->WordWrap = 50;
  46. $mail->IsHTML(true);
  47. $str1= "gmail.com";
  48. $str2=strtolower($_POST["uname"]);
  49. If(strstr($str2,$str1))
  50. {
  51. $mail->SMTPSecure = 'tls';
  52. $mail->Port = 587;
  53. if(!$mail->Send()) {
  54. echo "Mailer Error: " . $mail->ErrorInfo;
  55. echo "<br><br> * Please double check the user name and password to confirm that both of them are correct. <br><br>";
  56. echo "* If you are the first time to use gmail smtp to send email, please refer to this link :http://www.smarterasp.net/support/kb/a1546/send-email-from-gmail-with-smtp-authentication-but-got-5_5_1-authentication-required-error.aspx?KBSearchID=137388";
  57. }
  58. else {
  59. echo "Message has been sent";
  60. }
  61. }
  62. else{
  63. $mail->Port = 25;
  64. if(!$mail->Send()) {
  65. echo "Mailer Error: " . $mail->ErrorInfo;
  66. echo "<br><BR>* Please double check the user name and password to confirm that both of them are correct. <br>";
  67. }
  68. else {
  69. echo "Message has been sent";
  70. }
  71. }
  72. }
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement