Advertisement
Guest User

Untitled

a guest
Jul 13th, 2017
816
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.09 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
  4.  
  5. require 'mailer/class.phpmailer.php';
  6. require 'mailer/class.smtp.php';
  7.  
  8. $config = array(
  9.     'sendTo' => array('ooo.panorama@mail.ru'),
  10.     'from'   => array(
  11.         'email' => 'email@mail.ru',
  12.         'title' => 'panorama.ru'
  13.     ),
  14.     'smtp'   => array(
  15.         'host'      => 'smtp.mail.ru',
  16.         'debug'     => true,
  17.         'auth'      => true,
  18.         'port'      => 465,
  19.         'secure'    => 'ssl',
  20.         // 'username'   => 'email@mail.ru',
  21.         // 'password'   => 'password'
  22.     )
  23. );
  24.  
  25. if (isset($_POST['name']))   {$name  = htmlspecialchars(trim($_POST['name']));} else {$name = 'отсутствует';}
  26. if (isset($_POST['phone']))  {$phone = htmlspecialchars(trim($_POST['phone']));} else {$phone = 'отсутствует';}
  27. if (isset($_POST['email']))  {$email = htmlspecialchars(trim($_POST['email']));} else {$email = 'отсутствует';}
  28. if (isset($_POST['message']))    {$message = htmlspecialchars(trim($_POST['message']));} else {$message = 'отсутствует';}
  29. if (isset($_POST['title']))  {$title = htmlspecialchars(trim($_POST['title']));} else {$title = 'отсутствует';}
  30.  
  31. try
  32. {
  33.     $mail = new \PHPMailer (true);
  34.     $mail->IsSMTP();
  35.     $mail->Host         = $config['smtp']['host'];
  36.     $mail->SMTPAuth     = $config['smtp']['auth'];
  37.     $mail->SMTPSecure   = $config['smtp']['secure'];
  38.     $mail->Port         = $config['smtp']['port'];
  39.     $mail->Username     = $config['smtp']['username'];
  40.     $mail->Password     = $config['smtp']['password'];
  41.     $mail->CharSet      = 'utf-8';
  42.     $mail->Subject      = 'Сообщение с Вашего сайта panorama.ru';
  43.     $mail->IsHTML(true);
  44.     $mail->SetFrom($config['from']['email'], $config['from']['title']);
  45.     $mail->Body         = "<html>
  46.                             <head></head>
  47.                             <body>
  48.                                 <p> Тема: $title<br/>
  49.                                     Имя: $name<br/>
  50.                                     Телефон: $phone<br/>
  51.                                     E-mail: $email<br/>
  52.                                     Сообщение: $message
  53.                                 </p>
  54.                             </body>
  55.                             </html>";
  56.    
  57.     foreach ($config['sendTo'] as $emailSendTo) $mail->AddAddress($emailSendTo);
  58.     $send = $mail->Send();
  59. }
  60. catch (\phpmailerException $e)
  61. {
  62.      exit($e->errorMessage());
  63. }
  64.  
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement