0

We are trying to use Amazon SES to send automated verification emails to users that register. We have a shared hosting account, and have verified the domain on Amazon SES.

It works locally, but on the server, we keep getting this error:

"Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

We've searched through all similar posts, including this, but are still confused: what are we doing wrong?

Our web.config settings:

<appSettings>
    ...
    <add key="EMAIL_FROM_PREFIX" value="hey UD"></add>
    <add key="EMAIL_FROM" value="verify@heyud.com"></add>
    <add key="EMAIL_TO" value="admin@heyud.com"></add>
    <add key="EMAIL_SUBJECT" value="heyUD user verification"></add>

    <add key="SMTP_USERNAME" value="asdf"></add>
    <add key="SMTP_PASSWORD" value="asdf"></add>
    <add key="SMTP_HOST" value="email-smtp.us-east-1.amazonaws.com"></add>
    <add key="SMTP_PORT" value="25"></add>
  </appSettings>

Here's a screenshot of Elmah: https://www.dropbox.com/s/t2ngk0ddcy0c5q6/Screenshot%202014-01-31%2000.34.06.png

Community
  • 1
  • 1

1 Answers1

2

GoDaddy shared hosting tends to be very restrictive (especially when it comes to sending emails though SMTP).

Try using AmazonSimpleEmailServiceClient.SendEmail instead of SMTP.

AmazonSimpleEmailServiceClient client = 
    new AmazonSimpleEmailServiceClient("awsKey", "awsSecret");

SendEmailRequest req = new SendEmailRequest()
    .WithDestination(new Destination() { ToAddresses = new List<string> { "admin@heyud.com" } })
    .WithSource("verify@heyud.com")
    .WithReturnPath("verify@heyud.com")
    .WithMessage(
        new Amazon.SimpleEmail.Model.Message(new Content("Sup Bro?"),
        new Body().WithHtml(new Content("<em>Gurl look at ma body</em>, <b>I work out</b>"))));
                
var resp = client.SendEmail(req);

or forget SES all together and just do this: https://stackoverflow.com/a/5685126/585552 (the from address with have to match the domain of the site you're sending from)

Community
  • 1
  • 1
Greg
  • 8,574
  • 21
  • 67
  • 109
  • **Thanks a lot** - we followed your first suggestion (using SendEmail) and it's working now :) Wish I could vote up your answer, in addition to choosing it as the correct one... unfortunately, still don't have the required 15 rep. – Kavi Chokshi Jan 31 '14 at 11:35