Mittwoch, 22. Januar 2025

Sendgrid 501 Recipient syntax error

We're using the sendgrid.com SMTP API for sending mails. Recently we've seen an error pop up "501 Recipient syntax error". We quickly figured out that it was caused by an email address w. unicode characters (e.g. hvidløg@example.com). We checked the sendmail documentation, but it doesn't mention anything about that (just that specialchars in `from` need to be escaped). 

We checked with their support and figured out the solution. E-mail addresses (both local and domain part) need to be Punycode/IDN encoded. So our example email should look like 'xn--hvidlg@example-uqb.com'.