I am using php mailer to generate and send automatic e-mails when a form is submitted on my web site which is run on GoDaddy. Since GoDaddy has changed their e-mail platform from Workspace to Office365 last week, my website stopped sending automatic e-mails, because host was changed, and since new host (Office365) required new settings (like different port number and SMTPSecure info). So I made some changes on my php code as following:
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'smtp.office365.com';
$mail->Username = 'user#username.com';
$mail->Password = 'password';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->From = ('from#from.com');
$mail->addAddress('to#destination.com');
$mail->FromName = 'myname';
After changing host to office365, SMTPSecure info to 'tls' and Port number to 587, I started to get the following error:
SMTP ERROR: Failed to connect to server: An attempt was made to access
a socket in a way forbidden by its access permissions. (10013)
2022-10-08 08:35:07 SMTP connect() failed
I have tried following ports: 25, 80, 465 and 587.
I have tried following SMTPSecure types: 'tls', 'ssl', 'StartTLS'. But none of them worked.
I have also enabled SMTP authentication as advised in other answers. And tried all the alternative code snippets given in other questions but none of them worked.
Also, I have tried accessing my e-mail account and send automatic e-mail from Powershell. And it worked, so I think there is no issue with the e-mail account that I am using. So I'm thinking issue might be GoDaddy specific.
I have checked almost all of the questions and answers on websites but none of them worked. So I desperately need help to resolve this issue and start using my websites back. Any answer will be appreciated.
Thanks in advance.
I found the solution. Plesk hosting account allows sending e-mails to external e-mail servers via its own relay server (Detail is explained here by JesseW under GoDaddy's q/a portal). So when I changed my code as following the problem is solved and now I can send e-mails again.
$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = 'relay-hosting.secureserver.net ';
$mail->SMTPSecure = '';
$mail->Port = 25;
$mail->From = ('from#from.com');
$mail->addAddress('to#destination.com');
$mail->FromName = 'myname';
With relay mail server, port must be set to 25, Host must be changed as relay-hosting.secureserver.netSee link and SSL or Secure connection must be set to none.
Before that I have tried multiple servers (including office365 and exchange), multiple ports including 25 (with other hosts such as office365 etc.), 3535, 80, 465 and multiple SMTP Secure types, visited Azure, Office365 and GoDaddy Admin panels and changed SMTP Auth settings but none of them worked. The only problem with current configuration might be security-wise. I will look for secure access with ssl and tls settings next.
But at least code is now functional and working again.
When I sent email from server then it gives me two error -
SMTP Error: Could not connect to SMTP host. Message could not be sent.
Mailer Error: SMTP Error: Could not connect to SMTP host.
I found many hints on another answers on Stack overflow but doesn't work. I tried port no 465/587/65. Even below code works proper on my local system If i set port 587. But in server, It doesn't work.
require('class.phpmailer.php');
require('class.smtp.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPSecure = "ssl";
$mail->SMTPAuth = true;
$mail->Host = "smtp.gmail.com";
$mail->Username = "FromEmailId";
$mail->Password = "Password";
$mail->Port = 465;
$mail->From = "FromEmailId";
$mail->AddAddress("ToEmail");
$mail->IsHTML(true);
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
Try phpmailer in debug mode to check the error
$mail->SMTPDebug = 3; // Enable verbose debug output
First logout the your gmail account
then open this url
use this yrl
click the continue button
Next
change the port and SMTPsecure
$mail->SMTPSecure = "tls";
$mail->Port = 587;
The Gmail Help :
Still can't send mail?
If you tried configuring your SMTP server on port 465 (with SSL/TLS) and port 587 (with STARTTLS), but are still having trouble sending mail, try configuring your SMTP to use port 25 (with SSL/TLS).
This question failed to do a basic search and missed a vital piece of information later mentioned in comments: the OP is using GoDaddy. GoDaddy is well known to block outbound SMTP, so any suggestions relating to switching port numbers or security protocols will not help. You need to read other questions on GoDaddy's mail handling, and read their support documentation, which will push you in the direction of using GoDaddy's mail servers (using securehosting domains) or via localhost as a relay to the same. All of this is also covered in the PHPMailer troubleshooting guide.
In future, search before posting, as per the SO guidelines.
I am getting SMTP Error with PHP Mailer and Outlook SMTP. I am confused here because it is working fine on localhost with Port number 25 but It is not working on Hosting Server, I have tried all ports with SSL & TLS.
Error : SMTP ERROR: Failed to connect to server: Connection timed out (110)
My Code:
<?php
include("PHPMailer.php");
error_reporting(E_ALL);
ini_set('display_errors', '1');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.live.com";
$mail->SMTPDebug = 2;
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Username = "info#neelcomputech.com";
$mail->Password = "password";
$mail->Priority = 1;
$mail->CharSet = 'UTF-8';
$mail->ContentType = 'text/html; charset=utf-8\r\n';
$mail->From = "info#neelcomputech.com";
$mail->FromName = $name;
$mail->AddAddress("info#neelcomputech.com");
$mail->IsHTML(true);
$mail->Subject = "You got Message from Website";
$mail->Body = "testing";
if(!$mail->Send())
{
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else
{
echo 'success';
}
?>
Please help me to solve this issue. I have Shared Linux Hosting.
I had a similar problem, and it turned out my host (Bluehost) blocked outgoing connections on port 465. I will post the solution here in the hope that helps you. But I'm not expert enough to know if it's the same problem or not.
I found a wonderful how-to which fixed it for me:
In your cPanel DNS Zone editor, find the MX (Mail Exchanger) section, and select 'remote mail exchanger'.
In the cPanel email accounts section, create the appropriate email address (don't skip this)
Don't use "smtp.live.com" as your smtp host. Use the smtp host of your Shared Linux Hosting smtp. I don't know how you will get yours. Mine is boxXXXX.bluehost.com.
Set your username and password to be the same as the email account you just set-up in cPanel.
None of the answers worked for me.
After many hours, I found the problem, but only works for Cpanel/WHM
Login into WHM.
Go to ConfigServer Security & Firewall inside plugins option.
Click on Firewall configuration
Filter by SMTP Settings
Look for SMTP_ALLOWUSER option and add the Cpanel account's username separated by coma
Restart the Firewall.
If you don't have access to WHM ask your provider.
Hope it helps!
My code is correct.
The issue was with Hosting Provider. I contacted them about this and they did some configuration on their Server and it's done.
I have used phpmailer() concept to send mail to users from my shared server using php script, but I'm not able to send even though everything is right in my script according to phpmailer code.
My code like this:
$message = " This is testing message from my server";
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->Host = "smtp.gmail.com";
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "moorthi.mrk10#gmail.com"; // My gmail username
$mail->Password = "************"; // My Gmail Password
$mail->SetFrom("moorthi.mrk10#gmail.com");
$mail->Subject = "Test Mail from my Server";
$mail->Body = $message;
$mail->AddAddress($email);
if($mail->Send())
{
print json_encode("SUCCESS");
}
else
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
Note: I have used " GMail " as my SMTP server and SMTPSecure is " ssl " and port is "465" and username & passwords are my GMail username & password
I used VPS shared server and I kept my php script on that server.
I think there is no problem in my php script and I don't know why it doesn't work.
I got the ERROR like this.
2014-02-21 12:30:11 CLIENT -> SERVER: EHLO jkcorporates.com
2014-02-21 12:30:11 CLIENT -> SERVER: AUTH LOGIN
2014-02-21 12:30:11 CLIENT -> SERVER: bW9vcnRoaS5tcmsxMEBnbWFpbC5jb20=
2014-02-21 12:30:11 CLIENT -> SERVER: OTk0MTI0MTE0MA==
2014-02-21 12:30:11 SMTP ERROR: Password command failed: 534-5.7.14
534-5.7.14 i-_eumA> Please log in via your web browser and then try again.
534 5.7.14 54 k76sm17979938yho.18 - gsmtp
2014-02-21 12:30:11 CLIENT -> SERVER: QUIT
" The ERROR is " SMTP connect() failed.
Please give some solution for that.
Remember: I use Shared Server Name 'VPS.mydomain.com' and I want to use GMail as my SMTP server to send mail to users.
A bit late, but perhaps someone will find it useful.
Links that fix the problem (you must be logged into google account):
https://security.google.com/settings/security/activity?hl=en&pli=1
https://www.google.com/settings/u/1/security/lesssecureapps
https://accounts.google.com/b/0/DisplayUnlockCaptcha
Some explanation of what happens:
This problem can be caused by either 'less secure' applications trying to use the email account (this is according to google help, not sure how they judge what is secure and what is not) OR if you are trying to login several time in a row OR if you change countries (for example use VPN, move code to different server or actually try to login from different part of the world).
To resolve I had to: (first time)
login to my account via web
view recent attempts to use the account and accept suspicious access: THIS LINK
disable the feature of blocking suspicious apps/technologies: THIS LINK
This worked the first time, but few hours later, probably because I was doing a lot of testing the problem reappeared and was not fixable using the above method. In addition I had to clear the captcha (the funny picture, which asks you to rewrite a word or a sentence when logging into any account nowadays too many times) :
after login to my account I went HERE
Clicked continue
Use this:
https://www.google.com/settings/u/1/security/lesssecureapps
https://accounts.google.com/b/0/DisplayUnlockCaptcha
https://security.google.com/settings/security/activity?hl=en&pli=1
this link allow acces to google account
UPDATE 19-05-2017:
These url you must to visit from the IP address that will be send email
Solved the problem - PHPMailer - SMTP ERROR: Password command failed when send mail from my server
require_once('class.phpmailer.php');
include("class.smtp.php");
$nameField = $_POST['name'];
$emailField = $_POST['email'];
$messageField = $_POST['message'];
$phoneField = $_POST['contactno'];
$cityField = $_POST['city'];
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
$body .= $nameField;
try {
//$mail->Host = "mail.gmail.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->SMTPKeepAlive = true;
$mail->Mailer = "smtp";
$mail->Username = "xxxxx#gmail.com"; // GMAIL username
$mail->Password = "********"; // GMAIL password
$mail->AddAddress('sendto#gmail.com', 'abc');
$mail->SetFrom('xxxxxx#gmail.com', 'def');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML($body);
$mail->Send();
echo "Message Sent OK</p>\n";
header("location: ../test.html");
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
Important:
Go to google Setting and do 'less secure' applications enables. It will work.
It Worked for Me.
As others already suggested, you can enable the "less secure" applications or you can simply switch from ssl to tls:
$mailer->Host = 'tls://smtp.gmail.com';
$mailer->SMTPAuth = true;
$mailer->Username = "xxx#gmail.com";
$mailer->Password = "***";
$mailer->SMTPSecure = 'tls';
$mailer->Port = 587;
When using tls there's no need to grant access for less secure applications, just make sure, IMAP is enabled.
Login to your Gmail account using the web browser.
Click on this link to enable applications to access your account: https://accounts.google.com/b/0/DisplayUnlockCaptcha
Click on Continue button to complete the step.
Now try again to send the email from your PHP script. It should work.
I face the same problem, and think that I do know why this happens.
The gmail account that I use is normally used from India, and the webserver that I use is located in The Netherlands.
Google notifies that there was a login attempt from am unusualy location and requires to login from that location via a web browser.
Furthermore I had to accept suspicious access to the gmail account via https://security.google.com/settings/security/activity
But in the end my problem is not yet solved, because I have to login to gmail from a location in The Netherlands.
I hope this will help you a little! (sorry, I do not read email replies on this email address)
Just in caser anyone ends here like me.
In may case despite having enabled unsecure access to my google account, it refused to send the email throwing an SMTP ERROR: Password command failed: 534-5.7.14.
(Solution found at https://know.mailsbestfriend.com/smtp_error_password_command_failed_5345714-1194946499.shtml)
Steps:
log into your google account
Go to https://accounts.google.com/b/0/DisplayUnlockCaptcha and click continue to enable.
Setup your phpmailer as smtp with ssl:
$mail = new PHPMailer(true);
$mail->CharSet ="utf-8";
$mail->SMTPDebug = SMTP::DEBUG_SERVER; // or 0 for no debuggin at all
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->SMTPAuth = true;
$mail->Username = 'yourgmailaccount';
$mail->Password = 'yourpassword';
And the other $mail object properties as needed.
Hope it helps someone!!
You need to use an APP password.
Visit this link to view how to create one.
For those who are still unable to get it working, try the following in addition to the method provided by #CallMeBob.
PHP.ini
Go to C:\xampp\php , edit php.ini file with notepad.
Press CTRL+F on your keyboard, input sendmail_path on the search bar and click Find Next twice.
Right now, you should be at the [mail munction] section.
Remove the semicolon for this line:
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
Add a semicolon for this line:
sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"
SendMail.ini
Go to C:\xampp\sendmail, edit sendmail.ini file with notepad
Change the following:
smtp_server=smtp.gmail.com
smtp_port=465
auth_username=your-gmail-username#gmail.com
auth_password=your-gmail-password
force_sender=your-gmail-username#gmail.com
Note:
** smtp_port must tally with your those written in your php code.
** Remember to change your-gmail-username and your-gmail-password to whichever account you are using.
**
Hope this helps! :)
If you are G Suit user it can be solved by Administrator
Go to your Admin panel
Type in top search bar «Security» (Select Security with Shield icon)
Open Basic settings
Goto Less secure apps section
Press: Go to settings for less secure apps ››
And now select one of Radio Button
a) Disable access to less secure apps for all users (Recommended)
b) Allow users to manage their access to less secure apps
c) Enforce access to less secure apps for all users (Not Recommended)
Usually It does not working because of a)! And will start working immediately with c) option. b) – option will need more configuration for each user in GSuit
Hope it helps
This error is due to more security features of gmail..
Once this error is generated...Please login to your gmail account..there you can find security alert from GOOGLE..follow the mail...check on click for less secure option..Then try again phpmailer..
Your mail won't be sent online unless you complete the two-step verification for your g-mail account and use that password.
after publishing the code to the server, I am using gmail account to send a mail.
I followed the following steps to solve the issue
https://www.google.com/settings/u/1/security/lesssecureapps
https://security.google.com/settings/security/activity?hl=en&pli=1
if you added the 2 step verification then you need to remove to make it work
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