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.
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.