Reputation: 625
I am using XAMPP and when trying to send email through localhost
I get the following warning:
Warning:
stream_socket_enable_crypto()
: this stream does not support SSL/crypto inC:\xampp\htdocs\12work\class.smtp.php
on line 197
Here is my code:
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp.gmail.com"; // specify main and backup server
$mail->SMTPAuth = true;
$mail->Port = 25;
$mail->SMTPSecure = "tls";
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "mypassword"; // SMTP password
$mail->From = "[email protected]"; //do NOT fake header.
$mail->FromName = "MailMan";
$mail->AddAddress("[email protected]"); // Email on which you want to send mail
$mail->IsHTML(true);
$mail->Subject = "Just a Test";
$mail->Body = "Hello. I am testing <b>PHP Mailer.</b>";
if(!$mail->Send())
{
echo $mail->ErrorInfo;
}else{
echo "email was sent";
}
Upvotes: 16
Views: 50682
Reputation: 11
In my local system avast antivirus was on my computer I was not allowing any mail to be sent by SMTP Gmail once I disabled it, the emails were sent in the local system via SMTP
Upvotes: 1
Reputation: 635
In my local system avast mail shield was on I was not allowing any mail to be sent by smtp gmail once I disabled it, the mails were sending in local system via smtp
Upvotes: 4
Reputation: 7784
Alright, we need to enable Open SSL module. Here is how to do it:
php.ini
file;extension=php_openssl.dll
;
char.Hint:
If you are not familiar with php.ini
file, it is recommended to create a backup before modification. Ini is a configuration file and misconfigured or corrupted ini can result in that web server will not start.
If you are using LAMP stacks such as wamp, it should be possible to enable modules via graphic interface.
More about php.ini
: https://secure.php.net/manual/en/configuration.file.php
Upvotes: 51
Reputation: 349
Just a quick note,
you use $mail->Port = 25;
$mail->SMTPSecure = "tls";
Port should be 587 for gmail /tls
See https://support.google.com/mail/answer/78775?hl=el
Upvotes: 2