Configuring Mailgun for Your Website

Posted on | Updated:

Mailgun is an innovative way to send bulk mail from your application. With their simple pricing model you are given 50,000 emails for free every month. Why not take advantage of that and configure your site to send more reliably? Below is an overview on configuring Mailgun for your website.

  • Login to using the same credentials used to log into your Cloud Sites control panel.
  • Click on the Mailgun link located in the ‘More’ drop down menu item.


  • Your account will then sync with Mailgun and get you started.
  • Feel free to test sending mail out using the sandbox you are now provided with. Once you’ve done this, or chosen not to, click “Add Your Domain”


Preparing Mailgun for your website.

  • Input a domain to use. Since you are likely using email with this domain already, it’s suggested to use something like
  • Click Add domain.
  • Next we will need to add the DNS entries that are provided


If you will be receiving emails with Mailgun rather than your own email, 
make sure to change the MX records as described on the page. If you are 
already using another email solution, you’re done!

  • Once the records have been made, click Continue to Domain Overview

Domain Information

This screen appears similar, however, this particular screen contains the information you will be using to setup Mailgun with your domain. It also allows you to view the simple SMTP settings for your Mailgun account for when you want to use a basic SMTP form.


WordPress Integration


  • Leave Use HTTP API set to “Yes”
  • Install the Mailgun For WordPress plugin
  • Login to, click on more > mailgun
  • At your main Mailgun control panel, you will see your API Key and custom domains
  • In the Mailgun plugin settings,  input the API key custom domain you are using and an optional tag for tracking purposes
  • Save Changes, then Test Configuration to verify it works


  • Change Use HTTP API to “No”
  • Input the SMTP credentials we received earlier
  • Save and Test configuration

Now your WordPress is officially setup to use Mailgun for system emails such as password resets, login tracking, or anything else WordPress is set to use email for.

Using Mailgun For PHP Mail

Using the SMTP settings from the previous setup steps, we can setup a 
simple PHP SMTP script such as in this article:

Plug in your SMTP credentials and test the page. You’re done!

Using Mailgun in ASP

Using the SMTP settings from the previous setup steps allows us to setup a
simple .NET SMTP script as follows:

using System;
using System.Windows.Forms;
using System.Net.Mail;

namespace WindowsApplication1
public partial class Form1 : Form
public Form1()

private void button1_Click(object sender, EventArgs e)
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(“”);

mail.From = new 
mail.Subject = “Test Mail”;
mail.Body = “This is for testing SMTP mail from .NET 
through Mailgun”;

SmtpServer.Port = 587;
SmtpServer.Credentials = new 
System.Net.NetworkCredential(“USERNAME”, “PASSWORD”);
SmtpServer.EnableSsl = true;

MessageBox.Show(“mail Send”);
catch (Exception ex)

Plug in your SMTP credentials and test the page. You’re done!

For more information on how Cloud Sites by Rackspace can help you, check us out at cloud

Want more news and updates like this straight to your inbox?

Keep up to date with the latest​ ​Hosting news.