Search code examples
c#asp.net-mvc-3appharbormailgun

Sending an email using MailGun on AppHarbor


I'm trying to send a simple email to my users using AppHarbor and the MailGun addon. I also installed the MailGun NuGet package to send email easier from my C# code.

I get the following error:

System.InvalidOperationException: Domain not found

Here is the code I'm running:

/* Send welcome email. */
var client = new MailgunClient("foo.apphb.com", "key-1-jpn-190fj8102i3nf12i3fno213f");
client.SendMail(new System.Net.Mail.MailMessage("[email protected]", "[email protected]")
{
    Subject = "Hello from mailgun",
    Body = "this is a test message from mailgun."
});

Any ideas why this error message is popping up?


Solution

  • You probably shouldn't use foo.apphb.com when configuring the MailGun client. I'm guessing, but you should probably use the MAILGUN_SMTP_SERVER configuration variable that's injected when your app is deployed on AppHarbor.