PHPMailer not catching SMTP errors - phpmailer

I am using PHPMailer to connect to a remote smtp server running Exim.
In my exim logs, I can see that the sending failed, but PHPMailer does not catch an exception and it seems like the SMTP server is returning an "Ok" status.
Here is the excerpt from my exim log:
2019-06-27 17:03:00 1hgbXj-0000O5-Vl == *******#gmail.com R=dnslookup T=remote_smtp defer (-44) H=alt4.gmail-smtp-in.l.google.com [108.177.119.27]: SMTP error from remote mail server after RCPT TO:<********#gmail.com>: 452-4.2.2 The email account that you tried to reach is over quota. Please direct\n452-4.2.2 the recipient to\n452 4.2.2 https://support.google.com/mail/?p=OverQuotaTemp **** - gsmtp
And here is the (end of the) PHPMailer debug output:
SERVER -> CLIENT: 250 OK id=1hgbf8-0008CL-15
CLIENT -> SERVER: RSET
SERVER -> CLIENT: 250 Reset OK
Done #0.0734977722168s
CLIENT -> SERVER: QUIT
Any way I can see this error in PHP so that I can log the error in my application?

This is nothing to do with PHPMailer. The PHPMailer debug output shows a successful delivery to your exim server. That's where its involvement ends - at no point does PHPMailer talk to gmail, and so never sees this response.
Exim (as intended) then goes on to try to deliver the message, but receives a failure notice from gmail. What you should then see in your logs is an attempt by exim to bounce the message to the return path, which is set by your mail server from the SMTP envelope sender used to submit the original message. You can control this address by setting the Sender property in PHPMailer, though it defaults to your from address, which is what you'd usually want.
If you want to hear about these bounces in your code instead of your mailbox, you need to get exim to pipe them to a script rather than a mailbox, and this is something that exim is quite happy to do.
Bounce handling is not a pleasant thing to write, but you may find that using VERP addressing helps.

Related

throws SMTP error while sending an email in Lotus Notes

I'm trying to send the email from Notes which are of different domain mails. While sending an email i'm recieving an error "Error transfering to mail.target-domain.com; SMTP Protocol Returned a Permanent Error 554 5.7.1 <mail.my-domain.com: Access denied"
The configuration and the code level scripts are good and i don't see any error in code. Sometimes the mail send successfully, sometimes it throws such kind of error, sometimes if we retry to send email it sends.
I don't know where it throws an error
How to resolve this and why does this error appears?
It is not related to your script, it's a security configured in the server.
You have to work with your admin to understand if the security is triggered because of the FROM/sender address, the recipient address, your IP, or more probably the combo of sendername/recipient , or the SMTP relaying from some IP to some other IP.
Also, if your script is in an agent, the sender address is often forged by the agent/server, and is not a valid one.

PHPmailer send e-mail only sometimes

Im using PHPmailer to send email if user enter his e-mail. But sometimes (1/2 of emails) i get an error:
2013-10-15 11:12:39 SERVER -> CLIENT: 555 sorry, too many emails (#5.7.1)
2013-10-15 11:12:39 SMTP ERROR: Password command failed: 555 sorry, too many emails (#5.7.1)
2013-10-15 11:12:39 CLIENT -> SERVER: QUIT
2013-10-15 11:12:39 SERVER -> CLIENT:
2013-10-15 11:12:39 SMTP ERROR: QUIT command failed:
SMTP connect() failed.
In one of my project I also experienced this error. You reached the limit of emails you're allowed to send for this mailserver (preventing its usage as spam server). You could implement a queue to spread sending the mails over a given time or you could try to find another mail server. Mail servers of Internet Providers usually have good sending rates.

Oracle error on linux server when sending emails using sendmail

The ORACLE application is trying to send email using send mail running on a REDHAT LINUX server and the following error comes up, I don't have access to the code being a LINUX ADMIN and the application team sits on a remote location, just want to know what this error means exactly.
> ORA-29279: SMTP permanent error: 503 5.0.0 Need RCPT (recipient)
When I check the mail Log files around the same time, I see the line below, kindly guide me through to solve this issue.
sendmail[1812]: r6P80BgT001812: lost input channel from localhost.localdomain [127.0.0.1] to Daemon0 after data

Implications of Using SMTP Server when Sending Emails with Node.js

I want to send emails with my Node server. These are no-reply type emails, simply as reminders. The server will not need to handle incoming email. I know that there are services out there like Postmark, Mailchimp, etc. that will send emails for me, but I really do not want to pay for a service.
Using Nodemailer I have to specify a SMTP server. I can piggy back off of GMail or something but that's not desirable because the mail will not be coming from my domain (correct?).
But there is also node-sendmail which will send email without an SMTP server. Can someone describe the implications of sending email without an SMTP server? Dropped connections? No indication if message is undeliverable?
What are the implications of running my own SMTP server? Does it open up additional security holes? Can you recommend an open source SMTP server that requires minimal setup and maintenance?
Have a look at Haraka. It's an easy to use SMTP server that should do exactly what you're looking for. It's currently in use by Craigslist, so you know it's solid.
There's a section in the docs on how to set it up for sending mail - very last section 6.1.

SMTP to SMTP protocol

I am trying to write a fake SMTP server in nodejs, I just need use it to send notify email, but not receive email.
I have taken a look at node-smtp, but it just implements the protocol from client to SMTP server, it does not implement how to send mail from a SMTP server to another SMTP server.
If I know how one SMTP server send mail to another SMTP server, I think I can send mail without a SMTP server.
but it just implements the protocol from client to SMTP server, it does not implement how to send mail from a SMTP server to another SMTP server.
An SMTP server that can send mail also acts as an SMTP client. Not that you're trying to write an SMTP server anyway:
I just need use it to send notify email, but not receive email.
aka
I just need to write an SMTP client
Well in short it works this way: server-sender reads domain of recipient and is checking DNS for MX record for that domain (you can read it like - "hey DNS tell me please which server holds mails for that domain). Then it connects to remote SMTP and gives the messaage.
The dialogue could look like this:
client: HELLO server
server: 250 hello client, nice to meet you
client: MAIL FROM: tmg
server: 250 ok
client: RCPT TO: guilin
server: 250 ok
client: data
server: 354 Enter message, ending with "." on a line by itself
client: From: tmg
client: To: guilin
client: Subject: just a mail
client:
client: message body
client: .
server: 250 ok
client: quit
server: good bye
Did you look at Marak's node_mailer?
https://github.com/Marak/node_mailer
I have a fork of it, and another one, on my github site, for gmail smtp support
http://github.com/deitch
I use https://github.com/andris9/simplesmtp, it is actually a framework for creating SMTP servers/clients, however it is quite a good fit for testing.
There is also https://github.com/deitch/smtp-tester specially designed for testing, however I haven't used it.

Resources