Advertisement
Guest User

Untitled

a guest
May 26th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. <?php
  2. require("mailer/PHPMailerAutoload.php");
  3. require("mailer/class.smtp.php");
  4. require("mailer/class.phpmailer.php");
  5. $name=$_POST['Your_Name'];
  6. $email=$_POST['Your_Email'];
  7. $message=$_POST['Your_Msg'];
  8. echo $name ;
  9.  
  10. $mail = new PHPMailer();
  11.  
  12. // set mailer to use SMTP
  13. $mail->IsSMTP();
  14.  
  15. // we are setting the HOST to localhost
  16. $mail->Host = "smtp.gmail.com"; // specify main and backup server
  17. $mail->Port = "465";
  18.  
  19. $mail->SMTPAuth = true; // turn on SMTP authentication
  20.  
  21. $mail->Username = "mandarpatil0003@gmail.com"; // SMTP username
  22. $mail->Password = "Con@Soumitra1"; // SMTP password
  23. // $email is the user's email address the specified
  24. // on our contact us page. We set this variable at
  25. // the top of this page with:
  26. // $email = $_REQUEST['email'] ;
  27. $mail->From = $email;
  28.  
  29. // below we want to set the email address we will be sending our email to.
  30. $mail->AddAddress("mandarpatil0003@gmail.com", "Mandar");
  31.  
  32. // set word wrap to 50 characters
  33. $mail->WordWrap = 50;
  34. // set email format to HTML
  35. $mail->IsHTML(true);
  36.  
  37. $mail->Subject = "You have received feedback from your website!";
  38.  
  39. // $message is the user's message they typed in
  40. // on our contact us page. We set this variable at
  41. // the top of this page with:
  42. // $message = $_REQUEST['message'] ;
  43. $mail->Body = $message;
  44. $mail->AltBody ="Name : {$name}nnEmail : {$email}nnMessage : {$message}";
  45.  
  46. if(!$mail->Send())
  47. {
  48. echo "Message could not be sent. <p>";
  49. echo "Mailer Error: " . $mail->ErrorInfo;
  50. exit;
  51. }
  52. else
  53. {
  54. echo "Thank you for contacting us. We will be in touch with you very soon.";
  55. }
  56. ?>
  57.  
  58. <?php
  59. include 'library.php'; // include the library file
  60. include "classes/class.phpmailer.php"; // include the class name
  61. include "classes/class.smtp.php";
  62. if(isset($_POST["send"])){
  63. $email = $_POST["email"];
  64. $mail = new PHPMailer; // call the class
  65. $mail->IsSMTP();
  66. $mail->SMTPAuth = true; // turn on SMTP authentication
  67. $mail->SMTPSecure = "ssl";
  68.  
  69. $mail->Host = "smtp.gmail.com"; //Hostname of the mail server
  70. $mail->Port = 465; //Port of the SMTP like to be 25, 80, 465 or 587
  71. $mail->SMTPDebug = 1;
  72. //$mail->SMTPAuth = false; //Whether to use SMTP authentication
  73. $mail->Username = "****@gmail.com"; //Username for SMTP authentication any valid email created in your domain
  74. $mail->Password = "****"; //Password for SMTP authentication
  75. $mail->AddReplyTo("****@gmail.com", "Reply name"); //reply-to address
  76. $mail->SetFrom("****@gmail.com", "Your Name"); //From address of the mail
  77. // put your while loop here like below,
  78. $mail->Subject = "Your SMTP Mail"; //Subject od your mail
  79. $mail->AddAddress($email, "Asif18"); //To address who will receive this email
  80. $mail->MsgHTML("<b>Hi, your first SMTP mail has been received."); //Put your body of the message you can place html code here
  81. //Attach a file here if any or comment this line,
  82.  
  83. $send = $mail->Send(); //Send the mails
  84. if($send){
  85. echo '<center><h3 style="color:#009933;">Mail sent successfully</h3></center>';
  86. }
  87. else{
  88. echo '<center><h3 style="color:#FF3300;">Mail error: </h3></center>'.$mail->ErrorInfo;
  89. }
  90. }
  91. ?>
  92. <!DOCTYPE html>
  93. <html xmlns="http://www.w3.org/1999/xhtml">
  94. <head>
  95. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  96. <title>Send mails using SMTP and PHP in PHP Mailer using our own server or gmail server by Asif18</title>
  97. <meta name="keywords" content="send mails using smpt in php, php mailer for send emails in smtp, use gmail for smtp in php, gmail smtp server name"/>
  98. <meta name="description" content="Send mails using SMTP and PHP in PHP Mailer using our own server or gmail server"/>
  99. <style>
  100. .as_wrapper{
  101. font-family:Arial;
  102. color:#333;
  103. font-size:14px;
  104. }
  105. .mytable{
  106. padding:20px;
  107. border:2px dashed #17A3F7;
  108. width:100%;
  109. }
  110. </style>
  111. <body>
  112. <div class="as_wrapper">
  113. <h1>Send mails using SMTP and PHP in PHP Mailer using our own server or gmail server</h1>
  114. <form action="" method="post">
  115. <table class="mytable">
  116. <tr>
  117. <td><input type="email" placeholder="Email" name="email" /></td>
  118. </tr>
  119. <tr>
  120. <td><input type="submit" name="send" value="Send via SMTP" /></td>
  121. </tr>
  122. </table>
  123. </form>
  124. </div>
  125. </body>
  126. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement