Guest User

Untitled

a guest
Nov 26th, 2017
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. <?php
  2. #Адрес сервера
  3. $SmtpServer="mail.ya.ru";
  4. #Адрес порта
  5. $SmtpPort="25";
  6. #Логин авторизации на сервера SMTP
  7. $SmtpUser="username";
  8. #Пароль авторизации на сервера SMTP
  9. $SmtpPass="password";
  10.  
  11. #Класс работы с почтой
  12. class SMTPClient
  13. {
  14. function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
  15. {
  16. $this->SmtpServer = $SmtpServer;
  17. $this->SmtpUser = base64_encode ($SmtpUser);
  18. $this->SmtpPass = base64_encode ($SmtpPass);
  19. $this->from = $from;
  20. $this->to = $to;
  21. $this->subject = $subject;
  22. $this->body = $body;
  23. if ($SmtpPort == "")
  24. {
  25. $this->PortSMTP = 25;
  26. }
  27. else
  28. {
  29. $this->PortSMTP = $SmtpPort;
  30. }
  31. }
  32. function SendMail ()
  33. {
  34. if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
  35. {
  36. fputs ($SMTPIN, "EHLO ".$HTTP_HOST."rn");
  37. $talk["hello"] = fgets ( $SMTPIN, 1024 );
  38. fputs($SMTPIN, "auth loginrn");
  39. $talk["res"]=fgets($SMTPIN,1024);
  40. fputs($SMTPIN, $this->SmtpUser."rn");
  41. $talk["user"]=fgets($SMTPIN,1024);
  42. fputs($SMTPIN, $this->SmtpPass."rn");
  43. $talk["pass"]=fgets($SMTPIN,256);
  44. fputs ($SMTPIN, "MAIL FROM: <".$this->from.">rn");
  45. $talk["From"] = fgets ( $SMTPIN, 1024 );
  46. fputs ($SMTPIN, "RCPT TO: <".$this->to.">rn");
  47. $talk["To"] = fgets ($SMTPIN, 1024);
  48. fputs($SMTPIN, "DATArn");
  49. $talk["data"]=fgets( $SMTPIN,1024 );
  50. fputs($SMTPIN, "To: <".$this->to.">rnFrom: <".$this->from.">rnSubject:".$this->subject."rnrnrn".$this->body."rn.rn");
  51. $talk["send"]=fgets($SMTPIN,256);
  52. fputs ($SMTPIN, "QUITrn");
  53. fclose($SMTPIN);
  54. }
  55. return $talk;
  56. }
  57. }
  58.  
  59. if (isset($_POST['telephone'])) {$telephone = $_POST['telephone'];}
  60. if (isset($_POST['fio'])) {$fio = $_POST['fio'];}
  61. if (isset($_POST['email'])) {$email = $_POST['email'];}
  62. if (isset($_POST['sale'])) {$sale = $_POST['sale'];}
  63. if (isset($_POST['sale1'])) {$sale1 = $_POST['sale1'];}
  64. if (isset($_POST['prop'])) {$prop = $_POST['prop'];}
  65. if (isset($_POST['col'])) {$col = $_POST['col'];}
  66. if (isset($_POST['country'])) {$country = $_POST['country'];}
  67. if (isset($_POST['point'])) {$point = $_POST['point'];}
  68. if (isset($_POST['transport'])) {$transport = $_POST['transport'];}
  69. if (isset($_POST['suver'])) {$suver = $_POST['suver'];}
  70. if (isset($_POST['inshurance'])) {$inshurance = $_POST['inshurance'];}
  71.  
  72. /* Сюда впишите свою эл. почту */
  73. $address = "mail@mail.ru";
  74.  
  75. /* А здесь прописывается текст сообщения, n - перенос строки */
  76. $mes = "Тема: новый запрос!nФИО: $fionТелефон: $telephonenE-mail: $emailnВы хотите: $salenТовар: $sale1nКачественные характеристики: $propnКоличество: $colnСтрана назначения: $countrynПункт назначения: $pointnДополнительные сервисыnТранспорт и логистика $transportnСюрвейерские услуги: $suvernСтрахование поставки: $inshurance";
  77.  
  78. /* А эта функция как раз занимается отправкой письма на указанный вами email */
  79. $sub='Запрос услуг'; //сабж
  80. $email='robot'; // от кого
  81.  
  82. $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $email, $address, $sub, $mes);
  83. $SMTPChat = $SMTPMail->SendMail();
  84.  
  85. ?>
Add Comment
Please, Sign In to add comment