- Member | 2118
Today my application reported an error when sending e-mails. Here is the exception:
Nette\Mail\SmtpException: SMTP server did not accept RCPT TO:<vtr@lůl.cz> with error: 501 5.1.3 Bad recipient address syntax
All the e-mails are validated using
Nette\Utils\Validator::isEmail() so I thought it was safe from
invalid e-mail addesses.
Nette\Utils\Validator::isEmail('vtr@lůl.cz') does return true
though. Is it a bug in the validator or the SMTP server? Do you have a
recommendation how to fix it?
Is there some way to validate e-mail addresses using SMTP server instead of a regular expression?
No. It depends how is the SMTP server configured. It may reject message immediately when the envelope address is received (filter spam purpose usually), or it may accept whole message with success response code, but it can drops the message from the queue afterwards.
EDIT: If someove saw my previous post… sorry, I mistaken it with SMTP-to-SMTP server communication.
I tried to implement it, but there are some catches. I'm talking about IDN
hostname only, the part after
The SMTP commands
MAIL FROM and
RCPT TO have to be
EHLO localhost MAIL TO:<firstname.lastname@example.org> RCPT TO:<email@example.com>
But what about mail headers
I found on more places, that email headers can contain UTF-8 characters and
Thunderbird saves them in this way. And my SMTP server accepts them too. So
But google rejects such mail with:
Our system has detected that this message is 550-5.7.1 not RFC 2822 compliant.
Maybe some header is missing to use UTF-8 chars in headers, maybe IDN has to be punycoded in headers too. But I cannot find any explicit official specification.
Anybody more lucky wih Google?