S
S
SzarekhWH2019-05-14 18:01:44
PHP
SzarekhWH, 2019-05-14 18:01:44

I can't figure out why PHPMailer form submission is not working?

Can't get PHPMailer to work. I enter all the data in mail.php, but when I click the button on the form, nothing happens.
The form:

<form action="mail.php" method="POST" class="callback-form">
  <input type="text" placeholder="Ваше имя" name="user_name">
  <input type="text" class="mask_phone" placeholder="Ваш телефон" name="user_phone">
  <div class="clear"></div>
  <input type="submit" value="Позвоните мне !" class="submit">
</form>

5cdad6907e0f7298371529.png
mail.php file
<?php 

require_once('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer;
$mail->CharSet = 'utf-8';

$name = $_POST['user_name'];
$phone = $_POST['user_phone'];

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.beget.com';  					  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'instavoin'; // Ваш логин от почты с которой будут отправляться письма
$mail->Password = 'xxxxxx'; // Ваш пароль от почты с которой будут отправляться письма
$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to / этот порт может отличаться у других провайдеров

$mail->setFrom('[email protected]'); // от кого будет уходить письмо?
$mail->addAddress('[email protected]');     // Кому будет уходить письмо 
//$mail->addAddress('[email protected]');               // Name is optional
//$mail->addReplyTo('[email protected]', 'Information');
//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
//$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Заявка с тестового сайта';
$mail->Body    = '' .$name . ' оставил заявку, его телефон ' .$phone.;
$mail->AltBody = '';

if(!$mail->send()) {
    echo 'Error';
} else {
    header('location: ok.html');
}
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2019-05-14
@webinar

//$mail->SMTPDebug = 3; // Enable verbose debug output

uncomment to see errors

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question