Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. <?php
  2. include('SMTPconfig.php');
  3. include('SMTPClass.php');
  4. if($_SERVER["REQUEST_METHOD"] == "POST")
  5. {
  6. $to = $_POST['to'];
  7. $from = $_POST['from'];
  8. $subject = $_POST['sub'];
  9. $body = $_POST['message'];
  10. $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass,
  11. $from, $to, $subject, $body);
  12. $SMTPChat = $SMTPMail->SendMail();
  13. }
  14. ?>
  15.  
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  17. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  18. <html xmlns="http://www.w3.org/1999/xhtml">
  19. <head>
  20. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  21. <title>form</title>
  22. </head>
  23.  
  24. <body>
  25. <form method="post" action="">
  26. <table width="500px">
  27. <tr><td width="20%">To : </td>
  28. <td ><input type="text" name="to" /></td></tr>
  29. <tr><td>From :</td><td><input type='text' name="from" /></td></tr>
  30. <tr><td>Subject :</td><td><input type='text' name="sub" /></td></tr>
  31. <tr><td>Message :</td><td><textarea name="message"></textarea></td></tr>
  32. <tr><td></td><td><input type="submit" value=" Send " /></td></tr>
  33. </table>
  34. </form>
  35. </body>
  36. </html>
  37.  
  38. <?php
  39.  
  40.  
  41. class SMTPClient
  42. {
  43.  
  44. function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from,
  45. $to, $subject, $body)
  46. {
  47.  
  48. $this->SmtpServer = $SmtpServer;
  49. $this->SmtpUser = base64_encode ($SmtpUser);
  50. $this->SmtpPass = base64_encode ($SmtpPass);
  51. $this->from = $from;
  52. $this->to = $to;
  53.  
  54.  
  55. $this->subject = $subject;
  56. $this->body = $body;
  57.  
  58.  
  59. if ($SmtpPort == "")
  60. {
  61. $this->PortSMTP = 25;
  62. }else{
  63. $this->PortSMTP = $SmtpPort;
  64. }
  65.  
  66.  
  67. }
  68.  
  69.  
  70.  
  71. function SendMail ()
  72. {
  73.  
  74. if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
  75. {
  76.  
  77. fputs ($SMTPIN, "EHLO ".$HTTP_HOST."rn");
  78. $talk["hello"] = fgets ( $SMTPIN, 1024 );
  79.  
  80. fputs($SMTPIN, "auth loginrn");
  81. $talk["res"]=fgets($SMTPIN,1024);
  82. fputs($SMTPIN, $this->SmtpUser."rn");
  83. $talk["user"]=fgets($SMTPIN,1024);
  84.  
  85. fputs($SMTPIN, $this->SmtpPass."rn");
  86. $talk["pass"]=fgets($SMTPIN,256);
  87.  
  88. fputs ($SMTPIN, "MAIL FROM: <".$this->from.">rn");
  89. $talk["From"] = fgets ( $SMTPIN, 1024 );
  90. fputs ($SMTPIN, "RCPT TO: <".$this->to.">rn");
  91. $talk["To"] = fgets ($SMTPIN, 1024);
  92.  
  93. fputs($SMTPIN, "DATArn");
  94. $talk["data"]=fgets( $SMTPIN,1024 );
  95.  
  96.  
  97. fputs($SMTPIN, "To: <".$this->to.">rnFrom: <".$this->from.">rnSubject:".$this->subject."rnrnrn".$this->body."rn.rn");
  98. $talk["send"]=fgets($SMTPIN,256);
  99.  
  100. //CLOSE CONNECTION AND EXIT ...
  101.  
  102. fputs ($SMTPIN, "QUITrn");
  103. fclose($SMTPIN);
  104. //
  105. }
  106.  
  107. return $talk;
  108.  
  109.  
  110. }
  111.  
  112.  
  113.  
  114. }
  115.  
  116.  
  117. ?>
  118.  
  119. <?php
  120. $SmtpServer="smtp.mail.yahoo.com";
  121. $SmtpPort="465";
  122. $SmtpUser="username@yahoo.com";
  123. $SmtpPass="yahoopassword";
  124.  
  125. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement