Nette\Mail\SmtpException: Bad recipient address syntax

Notice: This thread is very old.
enumag
Member | 2118
+
0
-

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?

enumag
Member | 2118
+
0
-

Now I got a second exception – this time the e-mail address is valid but SMTP server refused it with message Recipient address rejected: Domain not found.

Is there some way to validate e-mail addresses using SMTP server instead of a regular expression?

Milo
Nette Core | 1283
+
0
-

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
+
0
-

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.

David Grudl
Nette Core | 8218
+
0
-

It can be converted via http://php.net/…to-ascii.php

Milo
Nette Core | 1283
+
0
-

I tried to implement it, but there are some catches. I'm talking about IDN hostname only, the part after @.

For example: hůla.czxn--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
+
0
-

What about this? https://tools.ietf.org/html/rfc6531 The EHLO keyword value associated with this extension is “SMTPUTF8”.

Milo
Nette Core | 1283
+
+1
-

I think that this RFC is for SMTP commands only, e.g: MAIL FROM:<míla@hůla.cz>. But I didn't read it whole. These RFCs about IDN are extremely boring.

Milo
Nette Core | 1283
+
0
-

Btw. CZ.NIC does not register IDN domains yet. Viz. http://háčkyčárky.cz/