Answer the question
In order to leave comments, you need to log in
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>
<?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 "Заявка принята!";
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question