send mail from application through other smtp server 25 - php

I'm facing below problem:
rcpt to: toxxxx#smtphost.com 454 4.7.1 toxxxx#smtphost.com
I'm facing below problem: telnet 10.5.2.28 25 Trying 11.1.2.21... Connected to 11.1.2.21. Escape character is... 220 smtp04.smtphost.com ESMTP Postfix HELO 171.21.1.21(application server) 250 smtp04.smtphost.com mail from: fromxxx#smtphost.com 250 2.1.0 Ok rcpt to: toxxxx#smtphost.com 454 4.7.1 <toxxxx#smtphost.com>: Relay access denied
: Relay access denied

The SMTP server that you are connecting to is not the MX for the recipient that you are trying to send the message to. So, to send the message, the SMTP server that you are connecting to would have to relay the message. The error that you are getting Relay access denied indicates that the SMTP server will not relay the message.
Did you authenticate with the SMTP server that you are connecting to? If not, then it's not surprising that you are seeing this error message, as otherwise this would be an open relay, and would probably quickly be abused by spammers.

Related

PHPMailer EOF caught while checking if connected

We've been using PHPMailer to send SMTP mail through Mailgun for years now.
We've recently upgraded our logging, and we've noticed that some mail just doesn't send.
Here is the SMTP log we're seeing:
Connection: opening to smtp.mailgun.org:587, timeout=300, options=array()
Connection: opened
SERVER -> CLIENT: SMTP
NOTICE: EOF caught while checking if connected
Connection: closed
SMTP Error: Could not connect to SMTP host.
SMTP Error: Could not connect to SMTP host.
This particular email was attempted to be sent with the Start TLS method via port 587.
How come most of our mail gets through but now and then we get this error?
Does anyone know what "EOF caught while checking if connected" could be caused by?
We're using the latest stable build of PHPMailer v6.1.5.
Thanks!
Thanks to advice from #Syncro and #Álvaro González and Mailgun themselves, I ended up building in a retry mechanism that attempts to send mail 3 times before failing.
So far this seems to be working, I will report back if anything changes!

Sending email through smtp-relay.gmail.com end up connecting to local smtp server

I have a Gsuite account. I setup a rule to allow SMTP relay through gmail servers, whitelisting my IP. Also, the FROM address is with my registered domain at Gsuite. And all my MX records point to google.
When trying to send a msg, the logs show that gmail accepts the connection, but in turn it passes is back to my local SMTP server.
Tried PHP PEAR mail & PHPMailer, same issue.
The logs start like this:
Connection: opening to smtp-relay.gmail.com:25, timeout=300, options=array ()
Connection: opened
SERVER -> CLIENT: 220-mylocalhosting.com ESMTP Exim 4.89 #1 Wed, 17 May 2017 23:44:41 -0400 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
From there on, I can send emails if using authentication from my own system.
In short, I specify gmail relay server, but my messages end up going out from my local mail server. And I can't understand why.
UPDATE: If the PHP script runs as 'root', gmail takes the message and processes it as expected:
Connection: opening to smtp-relay.gmail.com:25, timeout=300, options=array ()
Connection: opened
SERVER -> CLIENT: 220 smtp-relay.gmail.com ESMTP 137sm1646549itk.4 - gsmtp
But I can't make it do the same as a regular user.
Any assistance would be appreciated.
Found the problem: It's a setting in WHM SMTP Restrictions. WHM Manual

PHP can not send the mails from live.com smtp

I am trying to send the mails from my PHP page. I am using the live.com SMTP server to send the mails from my live account. When I try to send the mail from PHP I am receiving the error
Error: SMTP Connect() failed.
What may be the problem?
Here is my mail configuration.
define("EMAIL_USE_SMTP", true);
define("EMAIL_SMTP_HOST", "smtp.live.com");
define("EMAIL_SMTP_AUTH", true);
define("EMAIL_SMTP_USERNAME", "XXXXXXXXXXXXX#live.com");
define("EMAIL_SMTP_PASSWORD", "XXXXXXXXX");
define("EMAIL_SMTP_PORT", 587);
define("EMAIL_SMTP_ENCRYPTION", "ssl");
I also tried changing the host to smtp.mail.live.com and port to 25, and 465 also but still not working.
Check that the machine firewall is allowing the port and connection
Try telnet from the machine with:
telnet smtp.live.com 587
Did you get:
220 BLU436-SMTP67.smtp.hotmail.com Microsoft ESMTP MAIL Service, Version: 8.0.92
00.16384 ready at Fri, 18 Sep 2015 01:06:29 -0700
If you get below, try open the machine firewall
Could not open connection to the host, on port XXX: Connect failed

'No Relay Access Allowed' in Swift Mailer

I recently transferred my server to VPS & now email function doesn't work for external emails.
Following are the settings I'm using:
$transport = Swift_SmtpTransport::newInstance('ns1.example.com', 465, 'ssl')
->setUsername('testing#example.com')
->setPassword('password');
$mailer = Swift_Mailer::newInstance($transport);
And the error that I'm getting is this:
SMTP error from remote mail server after initial connection:
host dedrelay.where.example.net [XX.XXX.XXX.XX]: 554
m1plded02-01.prod.mesa1.example.net : DED :
gWqF1p02c0cB4sG01 : DED : ESMTP
No Relay Access Allowed From XXX.XXX.XXX
I've tried telnet & response is ok. I've tried following:
telnet ns1.example.com 465
Response was:
connected to xx.xxx.xxx.xx
I'm also not able to configure my desktop email client. Can anyone tell a solution? Any help will be appreciated.
EDIT
I'm not even able to send an email through server's webmail. Same error.
You tried telnet ns1.example.com 465 and it connected. This shows the SMTP server is up and running and your computer can reach it. But this is not all you need.
The error message No Relay Access Allowed From 123.123.123.123 means the SMTP server is configured to not accept emails from this IP address for relay, i.e. emails that needs to be passed to another server for delivery.
This is an anti-abuse measure and it means the SMTP server is configured correctly.
There is nothing wrong with your SwiftMailer configuration. Any email client (including the desktop client, as you said) you use, the answer is the same.
You need to contact the system administrator of the SMTP server and ask them to allow your IP address to use their SMTP server as relay. If they are your ISP it's also possible that the server allows relay only after authentication: you have an username/password pair (that you use to read the emails, f.e.) and you need to use it in order to send emails through their SMTP server. But this is only a supposition (this is how it usually works); you have to ask them to know for sure.

What causes this error: 554 5.7.1 [TPG-B01] Backscatter rejected to prevent DNSBL listings. Please reject mail during the SMTP session

I have a PHP script that attempts to send an email, but continually triggers this error on my local machine:
Warning: mail(): SMTP server response:
554 5.7.1 [TPG-B01] Backscatter rejected to prevent DNSBL listings.
Please reject mail during the SMTP session. For more information,
see http://spamlinks.net/prevent-secure-backscatter.htm
Googling reveals almost nothing about what that error means, and the URL referenced appears to be down. Does anyone know what causes it?
I finally tracked it down.
This error occurs when the mail envelope sender is empty, that is when it communicates with a remote SMTP server and sends something like this:
220 mail.tpg.com.au ESMTP (mail14) Sendmail ready.
HELO localhost
250 mail14.tpgi.com.au Hello [x.x.x.x] (may be forged), pleased to meet you
MAIL FROM:<>
250 2.1.0 <>... Sender ok
Even though it says "Sender ok", it's not OK. After sending the message, the 554 error above is triggered.
The solution is to ensure that PHP's sendmail_from setting is valid (and not empty). You can do this in your php.ini file, like so...
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from=foo#bar.com
Or within your script...
ini_set('sendmail_from', 'foo#bar.com');
Hope that helps somebody else out there. It took me hours to track this down.

Categories