Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Godaddy not sending to gmail #2912

Closed
andrearosen1 opened this issue Jun 10, 2023 · 9 comments
Closed

Godaddy not sending to gmail #2912

andrearosen1 opened this issue Jun 10, 2023 · 9 comments

Comments

@andrearosen1
Copy link

This is just a small test script created to see why I can't get PHPMailer to send to gmails accounts. The script appears to send to other accounts (look.ca, hotmail), but not to the gmail accounts tested (at least 4). Hosted by godaddy. When I uploaded to another client's website hosted by canaca.com, the script sends to the gmail accounts. I have also tried SMTP on the godaddy website and it appeared to send. Sendmail sends to all accounts tested (gmail, etc) outside of the PHPMailer library. This suggests to me that perhaps PHPMailer requires permissions to send to gmail. Godaddy added this txt record for me to the DNS: v=spf1 include:_spf.google.com ~all

Nothing seems to work. I modified the TXT record to include secureserver.net as a server and then the script sent but only to the first email. It caused problems for other forms (using wordpress and contact form 7), so I removed it as per godaddy's instructions.

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';

function mailEtransfer($data) {
$mail = new PHPMailer();
$mail->isSendmail();
$mail->setFrom("[email protected]", "xxxxx");
$mail->addAddress("[email protected]", "Andrea Rosen");
$mail->Subject = "XXXX Membership";
$mail->Body = "hi Andrea time 1208";
if($mail->send()){
echo "Message has been sent.";
}else{
echo "Message could not be sent.";
echo "Mailer Error: " . $mail->ErrorInfo;
}
}

@Synchro
Copy link
Member

Synchro commented Jun 10, 2023

There are some notes on GoDaddy in the troubleshooting guide. You don't need to call isSendMail(); the PHP mail client will work for that, though I'd still recommend SMTP to localhost. PHPMailer doesn't have any limitations or permissions about who you try to send to – it's entirely up to the mail servers you're sending through, and the settings of the recipient's server. You definitely cannot send from a gmail address through GoDaddy, but I don't know of them imposing any particular limits on sending to gmail addresses. Your SPF will not make any difference to who you can send to. The SPF record they made for you says that messages from your domain can be sent from gmail, which won't solve the problem you have here. If you're sending from GoDaddy, you have to send through their mail servers (the ironically named secureserver.net, which doesn't support encryption 🙄), which means you have to include their SPF record in yours.

@Synchro Synchro closed this as completed Jun 10, 2023
@andrearosen1
Copy link
Author

Thank you for this quick reply and for understanding the issue. Do you mean I should modify the DNS or perhaps just include the DNS in the script? When I added secureserver.net, the PHPMailer script sent to Gmail account if it was in the first email sent but it ignored the second email sent to any email address (I instantiated PHPMailer twice to send two emails in the original script). This was also the case for a form plugin - the second email would no longer be received. Perhaps I need the specific server: a2plcpnl0132.prod.iad2.secureserver.net? I have already seen and tried what was mentioned in the troubleshooting guide. Thanks for that as well.

@Synchro
Copy link
Member

Synchro commented Jun 10, 2023

This is another reason for using SMTP to localhost – you can see what your local mail server is doing when you submit messages by setting SMTPDebug = 2, whereas with sendmail or mail() mechanisms, you just get success or failure. I suggest you turn that on to see what's happening, and I can't really guess what it's doing without more detailed info. You don't need two instances for two messages, you can reuse the first one, and clear the recipient addresses between them with clearAddresses(), and perhaps gain a little speed by setting SMTPKeepalive = true.

@andrearosen1
Copy link
Author

andrearosen1 commented Jun 10, 2023

Thanks again. I had used the debug before and saw it sent; however, I did wonder about this line:

2023-06-10 17:05:41 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself

Full message follows.

2023-06-10 17:05:41 SERVER -> CLIENT: 220-a2plcpnl0132.prod.iad2.secureserver.net ESMTP Exim 4.95 #2 Sat, 10 Jun 2023 10:05:41 -0700 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
2023-06-10 17:05:41 CLIENT -> SERVER: EHLO nanps.org
2023-06-10 17:05:41 SERVER -> CLIENT: 250-a2plcpnl0132.prod.iad2.secureserver.net Hello nanps.org [127.0.0.1]250-SIZE 52428800250-8BITMIME250-PIPELINING250-PIPE_CONNECT250-AUTH PLAIN LOGIN250-STARTTLS250 HELP
2023-06-10 17:05:41 CLIENT -> SERVER: MAIL FROM:<[email protected]>
2023-06-10 17:05:41 SERVER -> CLIENT: 250 OK
2023-06-10 17:05:41 CLIENT -> SERVER: RCPT TO:<[email protected]>
2023-06-10 17:05:41 SERVER -> CLIENT: 250 Accepted
2023-06-10 17:05:41 CLIENT -> SERVER: DATA
2023-06-10 17:05:41 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
2023-06-10 17:05:41 CLIENT -> SERVER: Date: Sat, 10 Jun 2023 17:05:41 +0000
2023-06-10 17:05:41 CLIENT -> SERVER: To: Andrea R <[email protected]>
2023-06-10 17:05:41 CLIENT -> SERVER: From: Nanps <[email protected]>
2023-06-10 17:05:41 CLIENT -> SERVER: Subject: NANPS Membership
2023-06-10 17:05:41 CLIENT -> SERVER: Message-ID: <[email protected]>
2023-06-10 17:05:41 CLIENT -> SERVER: X-Mailer: PHPMailer 6.8.0 (https://github.com/PHPMailer/PHPMailer)
2023-06-10 17:05:41 CLIENT -> SERVER: MIME-Version: 1.0
2023-06-10 17:05:41 CLIENT -> SERVER: Content-Type: text/plain; charset=iso-8859-1
2023-06-10 17:05:41 CLIENT -> SERVER:
2023-06-10 17:05:41 CLIENT -> SERVER: hi Andrea 102
2023-06-10 17:05:41 CLIENT -> SERVER:
2023-06-10 17:05:41 CLIENT -> SERVER: .
2023-06-10 17:05:45 SERVER -> CLIENT: 250 OK id=1q8221-00Bcb4-DP
2023-06-10 17:05:45 CLIENT -> SERVER: QUIT
2023-06-10 17:05:45 SERVER -> CLIENT: 221 a2plcpnl0132.prod.iad2.secureserver.net closing connection
Message has been sent.

Here is the code:

$mail = new PHPMailer();
  $mail -> SMTPDebug = 2;
//function mailEtransfer($data) {
  $mail->isSMTP();
  $mail->Host = 'localhost';
  $mail->SMTPAuth = false;
  $mail->SMTPAutoTLS = false; 
  $mail->Port = 25; 
	
  $mail->setFrom('[email protected]', 'Nanps');
  $mail->addAddress('[email protected]', 'Andrea R');
  $mail->Subject = 'NANPS Membership';
  $mail->Body = 'hi Andrea 102';
  if($mail->send()){
          echo 'Message has been sent.';
  }else{
          echo 'Message could not be sent.';
          echo 'Mailer Error: ' . $mail->ErrorInfo;
  }

@Synchro
Copy link
Member

Synchro commented Jun 10, 2023

That transcript looks fine. That message is normal, and is just describing what the client's response to a 354 message from the server should be, which is to send the message, followed by a . by itself on a line – that's how the client tells the server "this is the end of the message". You can see it happening here:

2023-06-10 17:05:41 CLIENT -> SERVER: .

@andrearosen1
Copy link
Author

andrearosen1 commented Jun 10, 2023

Noticed that it says SERVER: QUIT. Do you know if that means it quit and didn't send?

@Synchro
Copy link
Member

Synchro commented Jun 10, 2023

More precisely it says CLIENT -> SERVER: QUIT, which is the client telling the server that it's finished and wants to to terminate the connection - which you a see happening immediately afterwards. If you set SMTPKeepalive = true, that is not sent, and you can then have it issue an RSET command instead (which PHPMailer takes care of for you), taking you back to just before the MAIL FROM command you can see earlier on in the output, and send another message without having to reconnect or reauthenticate. You can't do that if you use two instances.

@andrearosen1
Copy link
Author

First, thanks again for all the response. I will do the second email a different way. Are you suggesting that I do need to add the secureserver.net to the SPF TXT record? Unfortunately, that caused other mail issues (second email wasn't working for the form plugin and PHPMailer). Perhaps I need to be more specific and add this: a2plcpnl0132.prod.iad2.secureserver.net?

@Synchro
Copy link
Member

Synchro commented Jun 11, 2023

No, you should include GoDaddy's SPF as per their docs. It's their job to ensure that all their servers (of which there will be many, and probably change often) are in there. SPF is concerned with the IPs mail is coming from; the names don't matter. If you have a problem with your second mail, you need to show exactly what the problem is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants