PHPMailer: SMTP connect() failed - php

When I send a request to this, the request times out. This code has worked on another script in the same directory. I just logged into the gmail via browser to make sure all was good. The logged value of $mail->ErrorInfo is: SMTP connect() failed.
Any idea why this might work back in November but now throws an error when I copy it to another script?
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->CharSet = 'UTF-8';
$mail->Debugoutput = 'html';
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Username = "xxxxxx#gmail.com";
$mail->Password = "xxxxxxxxxx";
$mail->setFrom('xxxxxxxxxxx#gmail.com', 'xxxxxxxx');
$mail->addReplyTo('xxxxx#gmail.com', 'xxxxxx');
$mail->addAddress($email, $name);
$mail->Subject = 'Your License Information';
$mail->Body = $message;
I tried another gmail account and I've tried using the app password Gmail gives you.

Since I had it working before in same directory with similar code, I knew it had to be something weird. I tried ping google.com which didn't work and got me thinking about outbound traffic. Then I did ping 24.156.131.93 which is Google's IP (cutting out the domain resolver) and that worked, so I changed my nameservers in resolv.conf to Google's 8.8.8.8 and it now works. So basically, my host has some issues with their nameservers they provided, and the error wasn't just for SMTP but outgoing traffic is a whole.

Related

Could not authenticate Google account through PHPMailer

I'm using PHPMailer in a Simple Script For Send Email's Through Gmail, and I'm getting an this error (I'm sure that the email and password combination is correct):
!-- 2020-12-02 14:13:16 CLIENT -> SERVER: EHLO localhost
2020-12-02 14:13:16 CLIENT -> SERVER: STARTTLS
2020-12-02 14:13:17 CLIENT -> SERVER: EHLO localhost
SMTP Error: Could not authenticate.
2020-12-02 14:13:17 CLIENT -> SERVER: QUIT
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Allow less secure apps is ON
This is the way I implement the phpMailer
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
require './mailer/autoload.php';
$msg = "";
$mail = new PHPMailer();
try {
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_CLIENT;
$mail->isSMTP();
$mail->Host = 'smtp.google.com';
$mail->SMTPAuth = true;
$mail->Username = '********#gmail.com';
$mail->Password = '********';
$mail->SMTPSecure = "tls";
$mail->Port = 25;
$mail->CharSet= 'UTF-8';
$mail->setFrom('*******#gmail.com', 'Mailer');
$mail->addAddress($_POST["mail"]);
$mail->isHTML(true);
$mail->Subject = $_POST["subject"];
$mail->Body = '<h2>E-mail</h2>';
$mail->AltBody = $_POST["content"];
$mail->send();
} catch (Exception $e) {
$msg = "An Error has Ocurr";
}
How can I solve this issue?
SMTP port 25 is not used with TLS, you should use port 587 for TLS/STARTTLS or 456 for SSL. And it seems that you've also used the incorrect host URL, which should be smtp.google.com. The required configuration is stated here: https://support.google.com/mail/answer/7126229.
So you should probably change:
...
$mail->Host = 'smtp.google.com';
$mail->Port = 25;
...
To:
...
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
...
Depending on your situation, it might not be best practice to use Google's default SMTP. It is OK for personal use, but if you want to send more automated emails, you should look for other options. The default Google SMTP is strictly rate limited for example.
First of all, Google SMTP Relay yields a little more configurability if you need it.
When you really want to send automated or bulk emails, you should look into a provider specifically for this. It is not what the Google SMTP servers are made for and you will quickly notice by emails not being sent out or delivered properly.
It would really help if you actually read the error message and took the advice it gives you, by reading the guide it links to.
First of all, you're only showing client debug output, so you can't see what the server is saying, and so you can't tell what's going on, as the docs say. Do this:
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
Without seeing what that says, you're working blind.
That said, you get kicked out immediately after EHLO, and the only thing you have said is:
2020-12-02 14:13:17 CLIENT -> SERVER: EHLO localhost
Unfortunately this is untrue, and I'd guess that gmail is calling you out on it. localhost is by definition not an internet routable address, and any reverse lookup on the name will never match the IP you are connecting from, which is not localhost. If that is happening automatically, override it manually by setting the client host explicitly:
$mail->Helo = 'myhost.example.com';
While RFCs mandate port 587 for SMTP+STARTTLS, gmail supports it on port 25 too, and you can see that your STARTTLS command is working successfully, so that's not the problem here.
use port 587
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Username = '********#gmail.com';
$mail->Password = '********';

php mailer SMTP Error: Could not connect to SMTP host

I have hosted my website on Plesk Hosting and was working on submitting the contact form.
Installed PHP Mailer using composer.
First
I tried to send email using Gmail SMPT server
it worked fine
Second
I tried to send email using my webhosting SMTP Server
it is not working for me
$mail->Host = 'webmail.abc.in'; //host
$mail->SMTPAuth = false;
$mail->Username = '******#abc.in';
$mail->Password = '*******';
$mail->SMTPSecure = 'tls';
$mail->Port = 25;
I tested the SMPT server using SMTPER . it could send email using same credentials.
i dont know where the issue is..
is there any other library other then phpmailer??
This is a example of of code I'm using with gmail. Tested it with webhosting SMTP and worked as well.
` $mailMsg = ADD_MAIL_MESSAGE_HERE;
$mailto = ADD_TO_ADDRESS_HERE;
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->IsSmtp();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Username = ADD_USERNAME_HERE;
$mail->Password = ADD_PASSWORD_HERE;
$mail->SetFrom(ADD_FROM_ADDRESS_HERE);
//-------------------------------------------
$mail->Subject = ADD_MAIL_SUBJECT_HERE;
$mail->Body = $mailMsg;
$mail->AddAddress($mailto);
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
`
$mail->SMTPAuth = true;
As simple as that, I think.
You said you have tested the credentials on SMTPer,
I'm sure you checked the "Use authentication" checkbox.
Maybe you thought you could make it false because you are not using SSL,
But this is about user authentication, not about encrypted communication.
Are you using a Shared Hosting with Plesk? If yes, then this can probably be a port block issue (exact reason you will get only in the maillog). Looking at your code, I can see that in case of your local SMTP testing you are using port 25 while in case of Gmail it's 465.
By default, most of the shared hosting providers block the outgoing SMTP connection on port 25. This is done in order to protect the network and infrastructure from Spamming. If this is the case, then you need to contact their support to unblock the port or use some port free mode of email sending. Means instead of connecting over SMTP, connect over HTTP API for sending emails.

Sending Mail using PHP : SMTP ERROR

I am trying to send mail using php. But it gave me error,
" SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
"Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting" "
So that I searched alot to find the problem. There I got a solution, that I need to change $mail->IsMail(); from $mail->IsSMTP();
I did it and Mail was sent...
But when I checked my mail,
I got,
"This message may not have been sent by: sender#gmail.com"
Being a developer I understood that An email should not contain such lines or issues.
I want to know, Is it alright if Receiver is showing such line in Email? and if not that What should I do?
I mean what changes I should make in my code.
Here is my php code:
**
date_default_timezone_set('Etc/UTC');
include 'PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsSMTP();
// $mail->Mailer = "smtp";
$mail->SMTPDebug = 1;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "sender#gmail.com";
$mail->Password = 'senderPassword';
$mail->setFrom("sender#gmail.com", 'sender name');
$mail->addReplyTo('sender#gmail.com', '');
$mail->addAddress($receiver, '');
$mail->Subject = 'Welcome';
$mail->Body = 'body';
$mail->AltBody = 'This is a plain-text message body';
if (!$mail->send())
{
return "Mailer Error: " . $mail->ErrorInfo;
}
else
{
return array('flag' => "1");
}
**
isMail and isSMTP use two different sending mechanisms. isMail submits messages through the PHP mail() function, which delivers mail to a local mail server via a sendmail binary. This local mail server then tries to deliver the message to its ultimate recipient. It's possible that this local server will accept a message which is later rejected, and that will be too late for your script to know about.
With isMail:
script -> local mail server -> gmail
With isSMTP:
script -> gmail
With isMail you don't need to authenticate (localhost is usually allowed to relay), and the message is sent from your server to gmail. With isSMTP your message is sent from gmail to gmail, and it does require authentication.
When sending directly through gmail, you need to authenticate with gmail, and that has its own set of problems (that will be why your script is not working) covered thoroughly in the PHPMailer docs, examples and questions here on SO.
When sending via your server, you're saying that you are sending from a gmail user, but it's being sent by your server, not by a server listed in gmail's SPF record. This is forgery, which is why you are seeing the "This message may not have been sent by..." message. It would not say that if you sent from an address in your own domain.
The solution is to fix your gmail authentication and send directly through gmail. Base your code on the gmail example provided with PHPMailer, not the old, obsolete code you're using, and read the docs.
Here is the code which is use for mailing purpose. Try setting the SMTPDebug mode 3 and check the output.
$mail = new PHPMailer;
$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = 'smtp.office365.com';
$mail->SMTPAuth = true;
$mail->Username = 'xxxxxxxxxxxxxxx';
$mail->Password = 'xxxxxxxxxxxxx';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->From = 'xxxxxxxxxxxxxx';
$mail->FromName = 'xxxxxxxxxxxxxxxxx';
$mail->addAddress(xxxxxxxxxxxxxx);
$mail->addReplyTo('xxxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxx');
$mail->isHTML(true);
$mail->Subject = '';
$mail->Body = "";
$mail->send();

PHPMailer GoDaddy Server SMTP Connection Refused

The other day I was experiencing some problems with my GoDaddy hosted site. I called their tech support, and the person that I spoke with suggested that my problems were related to the fact that I was on a Windows box and would be better served on a Linux box. Having no opinion on this, I agreed and they switched me over.
In the wake of that transition, my PHPMailer functionality has deserted me. I have had this working for months, so I know that my settings are accurate. I have confirmed with GoDaddy that the account I am trying to send out of has not changed from their perspective. No changes have been made on the user side (like a new password). Bottom line, the only thing that is different is that my site is now hosted on a Linux server. That's it.
So I assume that my PHPMailer difficulties must be related to that, since it is too much of a coincidence that a script that has worked for months fails at the exact moment that the server transition occurs. But why? I spent an hour with their tech support, and they see nothing wrong with the server settings. We verified my settings (just for fun). Everything looks good, but when I send an email, I get this error:
SMTP -> ERROR: Failed to connect to server: Connection refused (111)SMTP Connect() failed.
There are many posts about this type of error, and almost all of them relate to people getting set up for the first time who have mis-entered settings or omitted settings. However, I KNOW that my settings are complete and accurate since I've been using them successfully for months. I'll post them here just for completeness:
$mail = new PHPMailer();
$mail->IsSMTP(); //telling the class to use SMTP
$mail->isHTML(true);
$mail->Host = "smtpout.secureserver.net"; //also tried "relay-hosting.secureserver.net"
$mail->WordWrap = 50;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->Username = "example#email.com";
$mail->Password = *******;
$mail->Subject = "Test Email";
$mail->SMTPDebug = 1;
Does anyone have any ideas why this might be happening? Is there some server setting that the tech support people might not be aware of, like maybe in my php.ini file? The guy I worked with did his best to help me out, but he may just not be aware of something.
Any help is appreciated. Let me know if there is any other information I can provide. Thanks!
EDIT: I should also mention some of the other attempts that I made. I get the same result no matter what.
1) TLS with port 587
2) Without SSL using ports 25, 80, and 3535.
2) My own gmail address modifying the server, username, password, etc.
I'm on GoDaddy on a Linux like #surfbird0713. On my 32nd attempt, the following worked for me as well:
$mail2->Host = localhost;
//$mail2->SMTPAuth = false;
//$mail2->Username = 'xxxx#xxxxxx.com';
//$mail2->Password = '*******';
//$mail2->SMTPSecure = 'tls';
//$mail2->Port = 465;
I was previously trying with the username, login, port, etc. When I commented out all those, and just went with localhost it worked.
As it seems this is a continuing problem, let me add my own experience.
Our website uses PHPMailer and the site is hosted on a GoDaddy linux server. The settings that seemed to be correct (according to everything I could find on SO and the goDaddy support site) were as follows:
SMTP_SERVER: smtpout.secureserver.net (or alternatively relay-hosting.secureserver.net)
SMTP_PORT: 465 //or 3535 or 80 or 25
SMTP_AUTH: true //always
SMTP_Secure: 'ssl' //only if using port 465
After spending 6+ hours trying every variation of ports(25, 3535, 4655), servers relay-hosting.secureserver.net,smtpout.secureserver.net:[port], etc.), usernames, passwords,etc. I called goDaddy. Another 40 minutes later, it was revealed that:
1) the "workspace" email accounts are being retired. That's important because if you have an email account with goDaddy today, you likely have a Workspace account. This is, according to the tech support rep, hosted separately from you linux account.
2) goDaddy is moving toward cPanel email accounts. Hurray! Time table? "...in the next 2 to 3 years!"
3) I moved our accounts from Workspace to cPanel accounts while I was on the phone with the rep. Really easy to do.
4) After you change your email accounts (including editing your MX records) to a cPanel email (vs. a "workspace" email) the appropriate settings for a web-form email using PHPMailer are:
SMTP_SERVER: localhost //(and I mean literally: "localhost"- in place of smtp.secureserver.net and relay-hosting.secureserver.net, etc.)
... and everything else (as above) the same...
The webform I built with PHPMailer worked perfectly after this change!
Use your cPaneL email account login (username) and password in the PHPMailer setup and your web emails will work seamlessly!
An added bonus is that webmail (does anybody use this anymore?) can be accessed at [yourdoman]\webmail. No more cryptic url's to remember! And the accounts cand be IMAP or POP!
Admittedly, this means you must use goDaddy's cPanel email accounts, but getting the webform to work flawslessly with PHPMailer was the real reward!
After a lot of frustration, this also worked for me.
include("includes/class.phpmailer.php");
date_default_timezone_set('UTC');
define('SMTP_HOST','relay-hosting.secureserver.net');
define('SMTP_PORT',25);**
define('SMTP_USERNAME','me#aravindnc.com');
define('SMTP_PASSWORD','me123');
define('SMTP_AUTH',false);
$email = 'aravind_n_c#yahoo.co.in';
$firstName = 'Aravind';
$mail = new PHPMailerR();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = SMTP_AUTH;
$mail->Host = SMTP_HOST;
$mail->Port = 25;
$mail->Username = SMTP_USERNAME;
$mail->Password = SMTP_PASSWORD;
$mail->SetFrom(SMTP_USERNAME,'AravindNC.IN');
$mail->AddReplyTo(SMTP_USERNAME,"AravindNC.IN");
$mail->Subject = "Welcome to AravindNC.IN";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML('This is a test.');
$mail->AddAddress($email, 'Aravind NC');
$mail->Send();
?>
these will be your SMTP settings for GoDaddy:
require("PHPMailer-master/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->From = "yourmail#ddd.com";
$mail->FromName = "name";
$mail->Host = "localhost";
$mail->SMTPAuth = false;
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
I have been experiencing this problem for many weeks. Finally, got it resolved.
First, I'd to state the causes of problem (as I experienced it).
GoDaddy allows only port 25, 465, 80 to get out. So, you cannot reach any SMTP server that are not using any of those 3 ports.
But if you are using SMTP from GMAIL per example, or any other replay server (especially from Bell Canada, on port 465), then any relay request from GoDaddy will be blocked - hence you will see the Connection Refused (111). Yes, they are competitors in hosting services... so draw your own conclusion on when this problem will get solved between them.
Worse, when you send an email from relay-hosting.secureserver.net provided by GoDaddy, you are facing a major inconvenience of long queuing that could take a couple of minutes to get the email out. Worse yet, people with Bell Canada (or Bell affiliates') email account will not see email from this relay server - the email does not even get to your spam box! As the email is completely blocked by Bell (their excuse = too much spams from GoDaddy).
So, recently I did this and it worked fine for me. If you have a hosting service with GoDaddy, then register an email account. Then using that email account, example mywebmail#mydomain.com, do this with PHPMail:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtpout.secureserver.net";
$mail->Username = "mywebmail#mydomain.com"; /*Substitute with your real email*/
$mail->Password = "myverylongpassword"; /*Substitute with your real password*/
$mail->SMTPAuth = true;
$mail->Port = 80;
Then do your regular PHPMailing things... This works great for me. I hope it does the same for you.
Earlier to make it work, the GoDaddy SMTP host was:
$mail->Host = 'smtpout.secureserver.net';
Then GoDaddy SMTP host was changed to:
$mail->Host = 'relay-hosting.secureserver.net';
But Now GoDaddy SMTP host which works properly is:
$mail->Host = 'localhost';
Also you can keep “SMTPAuth = false” and “Username/Password = Blank”. It doesn’t matters if you are using a GoDaddy Hosting Email or GoDaddy cPanel Email.
The main line of code is, so please make sure you include it:
$mail->SMTPAutoTLS = false;
You can copy whole of below code, it will work exactly as it is:
if(isset($_POST["submit"])){
include('phpmailer/PHPMailerAutoload.php');
//Create a new PHPMailer instance
$mail = new PHPMailer;
$mail->SMTPDebug = 0; // Enable verbose debug output
//SMTP settings start
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify main and backup SMTP servers
$mail->SMTPAuth = false; // Enable SMTP authentication
$mail->Username = ''; // SMTP username
$mail->Password = ''; // SMTP password
$mail->SMTPAutoTLS = false;
$mail->SMTPSecure = false; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25;
//Sender
$mail->setFrom('fromemail#domain.com');
//Receiver
$mail->addAddress('yourinbox#domain.com');
//Email Subject & Body
$mail->Subject = 'New Form Submission';
//Form Fields
$mail->Body = '
Name = '$name'
Email = '$email'
Subject = '$subject'
Message = '$message'
';
$mail->isHTML(true); // Set email format to HTML
//Send the message, check for errors
if (!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else {
echo 'Form Submitted Successfully.';
// code for saving in data in database can be added here
}
I have same problem But I tried this
$mail->SMTPAuth = false;
and HOSTNAME: relay-hosting.secureserver.net
And Bingoooooo its working
please just do once this setting in SMTP
GoDaddy/Linux (cPanel)/PHPMailer
require_once("../include/PHPMailer-master/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = "a2plcpnXXXXX.prod.iad2.secureserver.net";
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->Username = "your username";
$mail->Password = "your password";
$mail->SMTPSecure = "tls";
$mail->Port = 587;
Feel free to use whatever email/name you want for the $mail->From and $mail->FromName values. Hope this helps.
According to Godaddy, replace
$mail->Host = "smtpout.secureserver.net"; //also tried "relay-hosting.secureserver.net"
with
$mail->Host = "smtp.secureserver.net"; //also tried "relay-hosting.secureserver.net"
It worked for me.
Using some of the advice above I was able to get a turnkey bootstrap site up and running with email on shared hosting on GoDaddy.
I made an AJAX call to email.php which contained:
<?php
require 'PHPMailerAutoload.php';
if ($_POST) {
$name = $_POST['contactName'];
$email = $_POST['contactEmail'];
$message = $_POST['contactMessage'];
/* Don't touch */
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = "relay-hosting.secureserver.net";
$mail->SMTPAuth = false;
$mail->setFrom($email, $name);
/* end */
/* Configure the address the email will be sent to */
$mail->addAddress('administrator#stackchampion.com', 'Adam InTae Gerard');
$mail->Subject = 'Re: StackChampion Inquest';
/* This is forwarded through a GoDaddy forwarding account */
$mail->Body = $message;
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
}
?>
I put together a working demo on GitHub available here:
https://github.com/Thoughtscript/wp_postlib_godaddy_php_emailer
That's free to use and opensource but the relevant code is listed above. There are apparently a lot of problems with their SMTP servers - I've found that you can bypass that by using their offered relay servers which don't require authentication though they can still be associated with one of your registered emails acounts.
Hope that helps somebody!
Cheers!
After wrestling with this issue for a couple days and getting it to work I thought I would update this thread for 2017. Hopefully I can save someone a few wasted hours. I am hosted on Godaddy with cpanel. It was the SMTPAutoTLS setting I finally ran across and tried that was the missing piece. The error I was receiving is as follows:
PHP Warning: stream_socket_enable_crypto(): Peer certificate CN=*.prod.iad2.secureserver.net' did not match expected CN=localhost' in /home/username/public_html/classes/PHPMailer/class.smtp.php on line 369
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
The following are the PHPMailer settings that worked for me.
$mail->isSMTP();
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
$mail->SMTPAuth = false;
Well, I got this resolved, but not in a good way. After exhausting everything I could think of, I just threw my hands up and told GoDaddy to switch me back to the Windows server. As soon as they did that, the problem disappeared. Since I don't really care what type of server I'm on, this result is satisfactory, but hardly satisfying.
So, my advice for any GoDaddy customers who believe that they have PHPMailer set up correctly but can't make it work is to find out if you are on a Linux server. It looks to me like GoDaddy has their Linux servers set up to block this type of mail transaction. I can't say that definitively, since I only believe that because I failed at making it work. But I can clearly say that my PHPMailer setup was accurate, at least with Windows.
Maybe this will help save someone some time and frustration. If anyone has a better idea, please post.
if on your hosting have a own email server, your email server using the following ports 25,465,587.
Settings for GoDaddy:
$mail->isSMTP();
$mail->Host = localhost;
$mail->SMTPAuth = true;
$mail->Username = 'example#gmail.com';
$mail->Password = 'password';
//$mail->SMTPSecure = 'tls';
//$mail->Port = 587;
On the other servers need to create a mailbox with your domain:
$mail->isSMTP();
$mail->Host = localhost;
$mail->SMTPAuth = true;
$mail->Username = 'example#yourdomain.com';
$mail->Password = 'password';
//$mail->SMTPSecure = 'tls';
//$mail->Port = 587;
Update for Jan 2015: I just had to solve this exact problem. You need to have GoDaddy linux hosting with cPanel email accounts:
In the email accounts section, next to each email address in a dropdown, click the option to 'configure email client'.
On the next page, scroll down to 'Manual Settings'. Here you'll see that GoDaddy now creates a bespoke incoming/outgoing servers for each email address. So use the outgoing server, SSL, auth:true, port:465, email/password.
Hope that helps.
Change this:
$mail->Host = 'smtpout.secureserver.net:465';
$mail->SMTPSecure = "ssl";
To this:
$mail->Host = 'smtpout.secureserver.net:25';
and it worked for me!
If using cPanel and WPForms in WordPress
What helped me is to create email address from cPanel
and use its settings from Manual Settings section either with SSL or Non SSL
Godaddy is s nightmare.
If you are using an older work space email account and are unfamiliar with cpanel try this
require '/home/content/94/8357694/html/SHTECH/server/PHPMailer.php';
use PHPMailer\PHPMailer\PHPMailer;
function sendmail($to,$subject,$message,$name)
{
define('SMTP_HOST','relay-hosting.secureserver.net');
define('SMTP_PORT',25);
define('SMTP_AUTH',true);
$mail = new PHPMailer();
$mail->IsSMTP();
$mail -> SMTPDebug = 1;
$mail->Host = "smtpout.secureserver.net";
$mail->SMTPAuth = SMTP_AUTH;
$mail->Port = 80;
$mail->Username = "info#signalhilltechnology.com";
$mail->Password = "allen1";
//$mail->SMTPSecure = 'ssl';
$mail->SetFrom('info#signalhilltechnology.com', 'Cagney');
$mail->AddReplyTo("info#signalhilltechnology.com","Cagney");
$mail->Subject = $subject;
$body = $message;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $name);
if(!$mail->Send()) {
return 0;
} else {
return 1;
}
}
Just had this problem, contacted GoDaddy and they switched my MX over from Local to Remote and it solved the problem instantly! Just a heads up for anyone that is still experiencing this issue.
Updated 8-25-2019 For those seeking an answer to the proper way to set up Rd-Mailform and PHPmailer for Godaddy.
First off make sure that you have the latest files from Github.
Second here are the CORRECT settings for the Cpanel Email with SMTP and GODaddy
Edit the following file: rd-mailform.config.json (if your not using this file, then hard code in rd-mailform.php)
File to edit is:rd-mailform.config.json
~~~
"useSmtp": false,
"host": "localhost",
"port": 25,
"username": "youraccountname#yourdoamin.com",
"password": "yourpasswordforthataccount",
"recipientEmail": "youremailaddress"
~~~
Now after you have that edit open rd-mailform.php and edit the folling lines to be as follows:
// Whether to use SMTP authentication
$mail->SMTPAuth = false;
$mail->SMTPAutoTLS = false;
$mail->SMTPSecure = "tls";
That should work for all Godaddy servers using rd-mailform with phpmailer
-D
After hours of dirty work I realized that with go daddy, the configure mail client host details given for both SSL and TLS do not work. For this reason you have to copy part of the Cpanel url as your host.
**NB:**Make sure the url is what is resolved after typing your server ip and port on the search bar e.g 0:0:0:0:2083
The configuration should look something like
$smtp = Mail::factory('smtp', array (
'host' =>'2ueywefewueyuyeyryruw.prod.xxx.secureserver.net',
'port' => '587', 'auth' => true, 'username' => "youremail",
'password' => "yourEmailPassword", 'secure' => 'ssl'));
you can also refer to this link here
GoDaddy Server SMTP Connection Refused.
Bigrock
$mail->Port =587;// SMTP ser*vers
GoDaddy
$mail->Port =25;// SMTP ser*vers

Mail not sending with PHPMailer over SSL using SMTP

I am trying to use PHPMailer to send e-mails over SMTP but so far have had no luck. I've gone through a number of SO questions, PHPMailer tutorials and forum posts but still cannot get it to work. I'll document as many of my failed attempts as I can remember to save time, but firstly here is the code I am using:
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors','On');
require('includes/class.phpmailer.php');
include('includes/class.smtp.php');
$mail = new PHPMailer();
$name = $_POST["name"];
$guests = $_POST["guests"];
$time = $_POST["time"];
$message = "<h1>".$name." has booked a table for ".$guests." at ".$time."</h1>";
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "ssl://smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "myEmail#gmail.com"; // SMTP account username
$mail->Password = "myPassword"; // SMTP account password
$mail->SetFrom('myEmail#gmail.com', 'James Cushing');
$mail->AddReplyTo("myEmail#gmail.com","James Cushing");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($message)
$address = "myOtherEmail#me.com";
$mail->AddAddress($address, "James Cushing");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Firstly, when I run this code now I get two different errors. On my local server I get the error:
SMTP -> ERROR: Failed to connect to server: Operation timed out (60)
The following From address failed: myEmail#gmail.com : Called Mail() without being connected
Mailer Error: The following From address failed: myEmail#gmail.com : Called Mail() without being connected
I get moreorless the same error running the same code on my web server, but the first line is:
SMTP -> ERROR: Failed to connect to server: Network is unreachable (101)
Obviously it's worth pointing out that I'm not using the literal "myEmail#gmail.com" but I've substituted my own email out for this post.
Things I've tried
- Using the iCloud SMTP server
- Using a different port
- Enabling the OpenSSL extension in my php.ini file
- Copying code from various PHPMailer examples
- Using Google's "DisplayUnlockCaptcha" system to enable connections
- Sending to and from different addresses
- Removing the "#gmail.com" from the Username property
- A number of other things I can't remember
This has now been driving me mad for about a day, so if anyone can solve it they will be a hero.
Thanks
$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
Don't use SSL on port 465, it's been deprecated since 1998 and is only used by Microsoft products that didn't get the memo; use TLS on port 587 instead: So, the code below should work very well for you.
mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the
Firstly, use these settings for Google:
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls"; //edited from tsl
$mail->Username = "myEmail";
$mail->Password = "myPassword";
$mail->Port = "587";
But also, what firewall have you got set up?
If you're filtering out TCP ports 465/995, and maybe 587, you'll need to configure some exceptions or take them off your rules list.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
I got a similar failure with SMTP whenever my client machine changes network connection (e.g., home vs. office network) and somehow restarting network service (or rebooting the machine) resolves the issue for me. Not sure if this would apply to your case, but just in case.
sudo /etc/init.d/networking restart # for ubuntu
First, Google created the "use less secure accounts method" function:
https://myaccount.google.com/security
Then created the another permission:
https://accounts.google.com/b/0/DisplayUnlockCaptcha
Hope it helps.

Categories