Mail not sending with PHPMailer over SSL using SMTP
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Username = "myemail@gmail.com";
$mail->Password = "**********";
$mail->Port = "465";
That is a working configuration.try to replace what you have
Sending emails through SMTP with PHPMailer
As far as I can see everything is right with your code. Your error is:
SMTP Error: Could not authenticate.Which means that the credentials you've sending are rejected by the SMTP server. Make sure the host, port, username and password are good.
If you want to use STARTTLS, try adding:
$mail->SMTPSecure = 'tls';
If you want to use SMTPS (SSL), try adding:$mail->SMTPSecure = 'ssl';
Keep in mind that:- Some SMTP servers can forbid connections from "outsiders".
- Some SMTP servers don't support SSL (or TLS) connections.
[Source]
PHPMailer & STARTTLS not sending email
Not too complicated - your mail server does not support STARTTLS
. If it did it would appear in the list of capabilities after the first EHLO
command, which is this:
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250-8BITMIME
250-AUTH CRAM-MD5 PLAIN LOGIN
250-AUTH=CRAM-MD5 PLAIN LOGIN
250-XACK
250-SIZE 0
250-VERP
250 DSN
STARTTLS
is not in that list. It may still support encryption via SMTPSecure = 'ssl'
and Port = 465
, but otherwise you'll need to fall back to the most secure auth option over this unencrypted channel, which is AuthType = 'CRAM-MD5'
.ESMTP
just means that it supports "Extended SMTP" with EHLO
(and all that that implies), not just basic SMTP HELO
.
BTW - SMTPDebug = 4
is too noisy for this level of problem, you need 3 at most. Also, you're using an old version of PHPMailer, upgrade.
How can I send an email via PHPMAILER without SSL - port 25?
You've based your code on an old example, which doesn't help. You can't see what's going on because you've only used 1
for SMTPDebug
; set it to 2
.
Your mail server is advertising that it supports STARTTLS on port 25, so PHPMailer is using it automatically. You can disable encryption entirely by doing this:
$mail->SMTPAutoTLS = false;
$mail->SMTPSecure = false;
However, I'd recommend not doing this; fix your TLS config instead. You probably need to update your local CA certificate bundle - see the troubleshooting guide for more details. PHPMailer suddenly fails sending
There has been a rash of issues relating to Outlook lately – I suspect that they have stopped supporting some old TLS versions, and old PHP configurations that only have support for those old protocols will stop working. I think they are rolling this change out slowly across their many servers, so it will be be intermittent, but will happen increasingly often.
The solution is to update your PHP version.
Related Topics
Callback Function Using Variables Calculated Outside of It
How to Route Get and Post for Same Pattern in Laravel
How to Get the Root Url of the Site
Extend Request Class in Laravel 5
Typecasting VS Function to Convert Variable Type in PHP
How to Sort Null Values Last Using Eloquent in Laravel
Programming Multi-Language PHP Applications
How to Make a Chat Room Script with PHP
Rounding Up to the Second Decimal Place
MySQL into Outfile Override Existing File
Order Properties Should Not Be Accessed Directly - Woocommerce 3.0
File_Get_Contents('Php://Input') Always Returns an Empty String
Save Accents in MySQL Database