Guest User

SMTP Class

a guest
Dec 19th, 2017
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class SMTPClient
  5. {
  6.  
  7. function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to,$name,$subject,$mobile,$body)
  8. {
  9.  
  10. $this->SmtpServer = $SmtpServer;
  11. $this->SmtpUser = base64_encode ($SmtpUser);
  12. $this->SmtpPass = base64_encode ($SmtpPass);
  13. $this->from = $from;
  14. $this->to = $to;
  15. $this->name = $name;
  16. $this->subject = $subject;
  17. $this->mobile = $mobile;
  18. $this->body = $body;
  19.  
  20.  
  21. if ($SmtpPort == "")
  22. {
  23. $this->PortSMTP = 25;
  24. }else{
  25. $this->PortSMTP = $SmtpPort;
  26. }
  27.  
  28.  
  29. }
  30.  
  31.  
  32.  
  33. function SendMail ()
  34. {
  35.  
  36. if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
  37. {
  38.  
  39. fputs ($SMTPIN, "EHLO ".$HTTP_HOST."\r\n");
  40. $talk["hello"] = fgets ( $SMTPIN, 1024 );
  41.  
  42. fputs($SMTPIN, "auth login\r\n");
  43. $talk["res"]=fgets($SMTPIN,1024);
  44. fputs($SMTPIN, $this->SmtpUser."\r\n");
  45. $talk["user"]=fgets($SMTPIN,1024);
  46.  
  47. fputs($SMTPIN, $this->SmtpPass."\r\n");
  48. $talk["pass"]=fgets($SMTPIN,256);
  49.  
  50. fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n");
  51. $talk["From"] = fgets ( $SMTPIN, 1024 );
  52. fputs ($SMTPIN, "RCPT TO: <".$this->to.">\r\n");
  53. $talk["To"] = fgets ($SMTPIN, 1024);
  54.  
  55. fputs($SMTPIN, "DATA\r\n");
  56. $talk["data"]=fgets( $SMTPIN,1024 );
  57.  
  58.  
  59. fputs($SMTPIN, "To: <".$this->to.">\r\nFrom: <".$this->from.">\r\nSubject:".$this->subject."\r\n\r\n\r\n".$this->body."\r\n.\r\nMobile:".$this->mobile."\r\n\r\n\r\nName:".$this->name."\r\n\r\n\r\n");
  60. $talk["send"]=fgets($SMTPIN,256);
  61. fputs ($SMTPIN, "QUIT\r\n");
  62. fclose($SMTPIN);
  63. //
  64. }
  65.  
  66. return $talk;
  67.  
  68.  
  69. }
  70.  
  71.  
  72.  
  73. }
  74.  
  75.  
  76. ?>
Add Comment
Please, Sign In to add comment