-
|
Hi. Likely I'm going about it not quite right, but I succeeded in sending a message with a Unicode address to and from a server that nominally supports SMTPUTF8 using PHPMailer7. sender = me@gmail.com I skipped validation. (Only a test.) I did not find much (or any) documentation on When previously I attempted to send with the same parameters as above using PHPMailer6.60, A) debugging produced a warning that UseSMTPUTF8 is deprecated, and B) no email was sent. PHP7 sent the email to me+bücher@gmail.com. It arrived as me+bücher@gmail.com. Congratulations to the developer, and not 'deprecated'! Questions: Am I doing it right? Why no longer deprecated? Why deprecated in the first place? Comment: You cannot check if the server supports Unicode headers. A recipient will be aware however that if the email address is wrong, reply emails will end up being returned to the sending server marked 'Mail delivery failures'. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
After some more testing and validating this time, I came up with the following code to enable both Unicode and punycode, given that they are mutually exclusive.
Note: I dropped Please correct me, if this is in error. The bottom line is, you need to determine first that the address is SMTPUTF8 in order to validate.
|
Beta Was this translation helpful? Give feedback.
-
|
That helps. Thank you.
You are probably right about punycode conversion being unnecessary also. Gmail sends addresses like info@网站.亚洲. It depends on whether I continue to send the emails via Gmail. If instead I decide to stay with my hosting provider's mail server, it requires punycode. info@网站.亚洲 -> info@xn--5tzm5g.xn--jlqt95e. The receiving mail server should then be able to parse info@xn--5tzm5g.xn--jlqt95e, so it will arrive in the inbox of info@网站.亚洲. I have to fool around with Gmail some more. It may not be 100% reliable. Sometimes I get SMTP error messages, where the email is not sent. I'd post the error message here, but at the moment I can't reproduce it. Either way, that SMTPUTF8 is now supported by PHPMailer is nothing short of terrific. !!! |
Beta Was this translation helpful? Give feedback.
The
UseSMTPUTF8property is set dynamically inpreSend. It will automatically be assigned the appropriate value – setting it yourself will have no effect.By default PHPMailer uses PHP's built-in
filter_varvalidator, which does not handle SMTPUTF8 addresses. If you're expecting to use addresses that require SMTPUTF8, the validator needs to expect that, and until you've calledaddAddressand setCharSet, it can't know which validator to use automatically. So if you're calling it in isolation, you need to tell it which validator pattern to use beforehand. Add this near the top of your script, before you try to add any addresses:This is covered in the doc…