Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail recepients with German umlaut are not accepted #67

Open
michalbundyra opened this issue Jan 15, 2020 · 5 comments
Open

Mail recepients with German umlaut are not accepted #67

michalbundyra opened this issue Jan 15, 2020 · 5 comments

Comments

@michalbundyra
Copy link
Member

Cloned this from zf2 issue repository for correct assignment to zend-mail:

zendframework/zendframework#7654

Hi,

since ZF v2.4.x, I cannot send any mails to recepients containing German umlauts in their mail address.
For exmaple: testäöü@gmail.com
Encoding is set to UTF-8 on Zend\Mail\Message object.
The following expection is thrown:

Invalid header value detected #0 foobar\vendor\zendframework\zend-mail\src\Header\AbstractAddressList.php(114): Zend\Mail\Header\HeaderValue::assertValid('test\xC3\xA4\xC3\xB6\xC3\xBC@gmai...') #1 foobar\vendor\zendframework\zend-mail\src\Header\AbstractAddressList.php(158): Zend\Mail\Header\AbstractAddressList->getFieldValue(true) #2 foobar\vendor\zendframework\zend-mail\src\Headers.php(422): Zend\Mail\Header\AbstractAddressList->toString() #3 foobar\vendor\zendframework\zend-mail\src\Transport\Smtp.php(332): Zend\Mail\Headers->toString() #4 foobar\vendor\zendframework\zend-mail\src\Transport\Smtp.php(238): Zend\Mail\Transport\Smtp->prepareHeaders(Object(Zend\Mail\Message)) #5 foobar\vendor\Solar\library\Solar\Mail\Mail.php(144): Zend\Mail\Transport\Smtp->send(Object(Zend\Mail\Message)) #6 foobar\vendor\Solar\library\Solar\Client\AbstractClient.php(249): Solar\Mail\Mail->sendSmtp('processrevenuec...', Array, true, '') #7 foobar\modules\eonde\Processrevenuecheck.php(73): Solar\Client\AbstractClient->sendMail('test\xC3\xA4\xC3\xB6\xC3\xBC@gmai...', '', Array) #8 foobar\vendor\Solar\library\Solar\Bootstrap\Bootstrap.php(248): modules\eonde\Processrevenuecheck->run() #9 foobar\index.php(80): Solar\Bootstrap\Bootstrap->getResponse() #10 {main}

Umlauts work fine with the subject and body.
Also, the value passes the \Zend\Validate\EmailAddress validator.
It might be related to this issue although I cannot gain any workaround from it:
zendframework/zendframework#7501

Update:
Seems like RFC6531 was implemented in zend-validate but not yet zend-mail.


Originally posted by @renecatharsis at zendframework/zend-mail#49

@michalbundyra
Copy link
Member Author

AFAIK umlauts are not allowed in an email address (yet). The current accepted standard is RFC 2822 and non ASCII characters are not allowed in the local-part there. Non ASCII characters are proposed in RFC 6531. But this is still markes as PROPOSED STANDARD and was not implemented in
Zend\Validator\EmailAddress::validateLocalPart() (see: https://github.com/zendframework/zend-validator/blob/master/src/EmailAddress.php#L334). Which version of zend-validator do you use? isValid() returns false for me (2.5.3/latest stable).


Originally posted by @BreyndotEchse at zendframework/zend-mail#49 (comment)

@michalbundyra
Copy link
Member Author

I'm using v2.5.3 as well.
Installed by composer as part of zendframework/zendframework": "2.*
For me the validator returns true.
intl extension is loaded, the function idnToAscii actually calls PHP's idn_to_ascii function.

Running on a Win7 x64 with PHP7.0.0 wampstack, if that helps.


Originally posted by @renecatharsis at zendframework/zend-mail#49 (comment)

@michalbundyra
Copy link
Member Author

Oh. You're right. Intl was not loaded in my test environment. I have looked up RFC 6531, 6530, 5336, 5891 and 5890 and could not find any reference that the local-part could be converted to IDN ASCII. Actually there are some hints that the local-part SHOULD NOT be converted.

RFC 5891:

IDNA does not update the existing email standards, which allow only ASCII characters in local parts. Even though work is in progress to define internationalization for email addresses [RFC4952], changes to the email address part of the SOA RDATA would require action in, or updates to, other standards, specifically those that specify the format of the SOA RR.

(https://tools.ietf.org/html/rfc5891#section-3.2.2)

RFC 6530:

In order to use internationalized email addresses, it is necessary to internationalize both the domain part and the local part of email addresses. The domain part of email addresses is already internationalized [RFC5890], while the local part is not.

(https://tools.ietf.org/html/rfc6530#section-1)

IMO the behavior in zend-validator is wrong.

However google gave me some results of people claiming that some email providers actually support IDN converted local-parts. Let's ask @svyatoslav-kubakh who implemented IDN (zendframework/zendframework#7281). Maybe he can give us more information on this.


Originally posted by @BreyndotEchse at zendframework/zend-mail#49 (comment)

@arcaste
Copy link

arcaste commented Feb 21, 2020

For German umlaut you need to set UTF-8 with setEncoding method in \Laminas\Mail\Message()

@lklapa
Copy link

lklapa commented Apr 30, 2020

I also came across this issue. While I am aware of the rules of the RFC, the current behaviour is not consistent. An e-mail address with accents returns true for Laminas\Validator\EmailAddress validator, but the same e-mail is rejected by the Laminas\Mail\Header\HeaderValue's isValid().

The Laminas\Validator\EmailAddress has the option strict, but even though it defaults to true it doesn't take into account RFC 2822.

Is now only manual/additional validation the way to go? There is a mention of this in the validator: laminas/laminas-validator#7 and it looks like this issue is with the Laminas\Validator\EmailAddress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants