Nette\Mail\SmtpException: Bad recipient address syntax
- enumag
- 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?
- Milo
- Nette Core | 1283
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.
- Milo
- Nette Core | 1283
5.1.3 Bad recipient address syntax
The IDN in SMTP commands MAIL FROM
and RCPT TO
must
be in punycode. This is not implemented in the SmtpMailer.
- Milo
- Nette Core | 1283
I tried to implement it, but there are some catches. I'm talking about IDN
hostname only, the part after @
.
For example: hůla.cz
→ xn--hla-m1a.cz
The SMTP commands MAIL FROM
and RCPT TO
have to be
punycoded. So:
EHLO localhost
MAIL TO:<milo@xn--hla-m1a.cz>
RCPT TO:<test@xn--hla-m1a.cz>
But what about mail headers From:
and To:
?
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
From: <milo@hůla.cz>
.
But google rejects such mail with:
Our system has detected that this message is 550-5.7.1 not RFC 2822 compliant.
But accepts From: <milo@milo@xn--hla-m1a.cz>
.
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?
- David Grudl
- Nette Core | 8218
What about this? https://tools.ietf.org/html/rfc6531 The EHLO keyword value associated with this extension is “SMTPUTF8”.