Using Mailgun
Mailgun provides a complete email platform for sending,
receiving and hosting emails. Installing the add-on is simple and
is automatically integrated with your current SMTP configuration if
you're using the <smtp/>
element of the
<mailSettings/>
section in
<system.net/>
. If you need to use other Mailgun
features or configure your app in a different way, you can easily
fetch the necessary configuration variables from your
<appSettings/>
. Both approaches are described
below.
Automatic Installation
If you're using the standard SmtpClient
to send
emails and use your configuration file to configure it, you're in
luck. We'll simply replace the <smtp/>
configuration section when your application is deployed with the
values from the Mailgun add-on.
In development you could have a configuration like this in your "Web.config" file and run a development SMTP server (like smtp4dev) on localhost:
<configuration>
<system.net>
<mailSettings>
<smtp>
<network host="localhost" port="25" />
</smtp>
</mailSettings>
</system.net>
</configuration>
You don't have to define this section. If it's there, we'll replace it, but if not, we'll still insert it.
Manual Installation
If you prefer to use another client you can do so by fetching
the relevant configuration from your appSettings. You can see the
values and name of the <appSettings/>
keys on
your application's page under "Variables".
The variables are called:
- MAILGUN_API_KEY
- MAILGUN_SMTP_LOGIN
- MAILGUN_SMTP_PASSWORD
- MAILGUN_SMTP_PORT
- MAILGUN_SMTP_SERVER