Skip to content

Instantly share code, notes, and snippets.

@Dexdot
Created January 8, 2020 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dexdot/352da9c8143f7188a22a5ff41a683326 to your computer and use it in GitHub Desktop.
Save Dexdot/352da9c8143f7188a22a5ff41a683326 to your computer and use it in GitHub Desktop.
smtp test
<?php
$username=$_POST['form_name'];
$phone=$_POST['form_phone'];
$message = "
Имя: ".htmlspecialchars($username)."<br />
Телефон: ".htmlspecialchars($phone);
require_once('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer;
$mail->CharSet = 'utf-8';
$mail->isSMTP();
$mail->Host = 'smtp.yandex.ru';
$mail->SMTPAuth = true;
$mail->Username = 'username@yandex.ru';
$mail->Password = 'password';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->SMTPDebug = 2;
$mail->setFrom('username@yandex.ru', 'SHUBOX - заявка с сайта');
$mail->addAddress('dolotter@gmail.com');
$mail->isHTML(true);
$mail->Subject = 'SHUBOX - заявка с сайта';
$mail->Body = $message;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment