Today I did some mailings in php, I found that there are two methods for this - a simple mail function provided by Php, and the second one I found on the Internet related to using the PHP mailer class from https://github.com/ PHPMailer / PHPMailer . the problem is that I run my program, than the mail is not sent. Let's take a look at the code
<?php
include 'PHPMailer-master/class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->IsHTML(true);
$mail->Username = "singh6@gmail.com";
$mail->Password = "88888*******";
$mail->SetFrom('singh@gmail.com');
$mail->AddAddress('sanu@gmail.com');
$mail->Subject = "Test";
$mail->Body = "hello";
$sendResult = $mail->Send();
if ($sendResult)
{
echo "Message has been sent";
}
else
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
Now when I run this script, I get the following error:
CLIENT -> SMTP: EHLO localhost
SMTP -> ERROR: EHLO not accepted from server:
CLIENT -> SMTP: HELO localhost
Note: fwrite (): send error of 16 bytes with errno = 10054 An existing connection was forcibly closed by the remote host. in C: \ xampp \ htdocs \ program \ mailsending1 \ mailsending_v1 \ PHPMailer-master \ class.smtp.php on line 1023
SMTP -> ERROR: HELO not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connected
SMTP Connect() failed.
Mailer Error: SMTP Connect() failed.