Advertisement
Guest User

Untitled

a guest
Nov 30th, 2017
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.20 KB | None | 0 0
  1. index.php
  2. <?php
  3. include('SMTPconfig.php');
  4. include('SMTPClass.php');
  5. if($_SERVER["REQUEST_METHOD"] == "POST")
  6. {
  7. $mail = $_POST['mail'];
  8. $from = $_POST['from'];
  9. $subject = $_POST['sub'];
  10. $body = $_POST['message'];
  11. $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $mail, $subject, $body);
  12. $SMTPChat = $SMTPMail->SendMail();
  13. }
  14. ?>
  15.  
  16.  
  17. <form method="post" action=""><br>
  18. Mail:<input type="text" name="mail" /><br>
  19. From :<input type='text' name="from" /><br>
  20. Subject :<input type='text' name="sub" /><br>
  21. Message :<textarea name="message"></textarea><br>
  22. <input type="submit" value=" Send " />
  23. </form>
  24.  
  25. SMTPclass.php
  26. <?php
  27. class SMTPClient
  28. {
  29.  
  30. function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $mail, $subject, $body)
  31. {
  32.  
  33. $this->SmtpServer = $SmtpServer;
  34. $this->SmtpUser = base64_encode ($SmtpUser);
  35. $this->SmtpPass = base64_encode ($SmtpPass);
  36. $this->from = $from;
  37. $this->mail = $mail;
  38. $this->subject = $subject;
  39. $this->body = $body;
  40.  
  41. if ($SmtpPort == "")
  42. {
  43. $this->PortSMTP = 25;
  44. }
  45. else
  46. {
  47. $this->PortSMTP = $SmtpPort;
  48. }
  49. }
  50.  
  51. function SendMail ()
  52. {
  53. if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
  54. {
  55. fputs ($SMTPIN, "EHLO ".$HTTP_HOST."\r\n");
  56. $talk["hello"] = fgets ( $SMTPIN, 1024 );
  57. fputs($SMTPIN, "auth login\r\n");
  58. $talk["res"]=fgets($SMTPIN,1024);
  59. fputs($SMTPIN, $this->SmtpUser."\r\n");
  60. $talk["user"]=fgets($SMTPIN,1024);
  61. fputs($SMTPIN, $this->SmtpPass."\r\n");
  62. $talk["pass"]=fgets($SMTPIN,256);
  63. fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n");
  64. $talk["From"] = fgets ( $SMTPIN, 1024 );
  65. fputs ($SMTPIN, "RCPT mail: <".$this->mail.">\r\n");
  66. $talk["mail"] = fgets ($SMTPIN, 1024);
  67. fputs($SMTPIN, "DATA\r\n");
  68. $talk["data"]=fgets( $SMTPIN,1024 );
  69. fputs($SMTPIN, "mail: <".$this->mail.">\r\nFrom: <".$this->from.">\r\nSubject:".$this->subject."\r\n\r\n\r\n".$this->body."\r\n.\r\n");
  70. $talk["send"]=fgets($SMTPIN,256);
  71. //CLOSE CONNECTION AND EXIT ...
  72. fputs ($SMTPIN, "QUIT\r\n");
  73. fclose($SMTPIN);
  74. //
  75. }
  76. return $talk;
  77. }
  78. }
  79. ?>
  80.  
  81.  
  82. SMTPconfig.php
  83. <?php
  84. //Server Address
  85. $SmtpServer="smtp-relay.gmail.com";
  86. $SmtpPort="25"; //default
  87. $SmtpUser="andreas.enemyr@gmail.com";
  88. $SmtpPass=":)))";
  89. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement