A
A
Artem2016-12-16 16:50:11
SMTP
Artem, 2016-12-16 16:50:11

Why are emails not sent via SMTP + PHPMailer + mail.yandex.ru?

Tell me where the mistakes are made.
The form:

<form action="zvonok.php" method="post" id="messege">
              <input name="name" type="text" maxlength="20" placeholder="Ваше имя *" required>
              <input name="tell" type="text" maxlength="20" placeholder="Номер телефона *" required>
          <input type="submit" value="Позвоните мне" class="btn-nomer">
        </form>

zvonok.php file:
<?php 

require_once('phpmailer/class.phpmailer.php');

$username = $_POST['name'];   // сохраняем в переменную данные полученные из поля c именем
$usertel = $_POST['tell']; // сохраняем в переменную данные полученные из поля c телефонным номером
 
$mail = new PHPMailer();

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "mail.yandex.ru"; // SMTP server
$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "mail.yandex.ru"; // sets the SMTP server
$mail->SMTPSecure = 'ssl';                 // Enable TLS encryption, `ssl` also accepted
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
$mail->Username   = "[email protected]сайт.ру"; // SMTP account username
$mail->Password   = "пароль";   // SMTP account password

$mail->SetFrom('[email protected]сайт.ру', 'Администратор');

$mail->Subject    = "Заказ обратного звонка";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($username, $usertel);

$address = "почта назначения";
$mail->AddAddress($address, "Имя");

if(!$mail->Send()) {
  echo "Ошибка..." . $mail->ErrorInfo;
} else {
  echo "Заявка принята!";
}
 
?>

Everything is set up on the hosting, everything is activated in the Yandex mail for domain panel, the class.phpmailer.php file is in place.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2016-12-18
@dimonchik2013

logs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question