Trouble using display name for AWS SES sender address
I'm working in .NET with the AWS SDK for Amazon SES mail. I'm trying to add a display name to the sender address like so:
using (var client = new AmazonSimpleEmailServiceClient(RegionEndpoint.USWest2))
{
var sendRequest = new SendEmailRequest
{
Source = "My Website <noreply@mywebsite.com>"
Sometimes this works, but sometimes it throws an exception:
Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext executionContext, HttpErrorResponseException exception) Local address contains control or whitespace.
When it fails, it seems as if it's trying to validate the display part as if it were the email address.
I know with the Amazon SES SMTP Interface I can set the sender address like so:
MailMessage message = new MailMessage();
message.From = new MailAddress("noreply@mywebsite.com", "My Website");
and the desired "My Website noreply@mywebsite.com" is achieved and works fine. But if I want to use the AWS SDK, I get this error intermittently. Has anyone else seen this or know what's going on? It seems as if the display name in AWS SDK may just not be supported.
If you want to specify the display name ('friendly name') that contains spaces, you should put that sender name in double quotes. Do not forget to escape them:
Source = "\"My Website\" <noreply@mywebsite.com>"
In general, always prefer that format.
Please refer to the Amazon SES Developer Guide. Please also refer to the RFC5322 standard.
Relevant questions
Undelivered Mail Returned to Sender
asked 4 months agoConfigure PHP Laravel client to send messages from an AWS Workmail Account
asked a month agoError log when i try to authenticate my SMTP
asked 2 months agoAmazon SES Identity Management verification issue
Accepted Answerasked 3 years agoMust I verify all my emails destination?
asked 3 years agoTrouble using display name for AWS SES sender address
Accepted Answerasked 10 days agoSetting the 'From' alias in Pinpoint Email Campaigns.
asked 3 years agoSave emails sended by Amazon SES in Amazon Workmail Sent Items
asked 3 years agoFROM Email Address - Sender Name
asked 3 years agoProper handling of SES bounces sent to sender's reply address (when already using SNS service to handle bounces)
Accepted Answerasked 5 months ago
This worked for me, though since it worked intermittently in the past, I can't fully test it. I didn't find anything in the documentation about surrounding the friendly name in quotes in case of whitespace, but since the quote marks don't show up literally in the email header when delivered, it makes sense that they would be acting to delimit the contents as a single string. We'll go with it. Thanks.