Configuring Mailgun for your website

Mailgun is an innovative way to send bulk email from your application. Rackspace Cloud customers are given 50,000 emails every month at no cost. To take advantage of that value and configure your website to send email more reliably, use the steps in this article to configure Mailgun for your website.

Activate Mailgun for your account

  1. Log in to the Cloud Control Panel by using your Rackspace Cloud account credentials.
  2. At the top of the panel, click the Rackspace Cloud menu and then select Mailgun.

    Your account synchronizes with Mailgun, and the Mailgun Control Panel opens.

  3. (Optional) Send a test email by using the sandbox that Mailgun provides you.

  4. Click Add Your Domain.

Prepare Mailgun for your website

  1. Enter the name of a domain to use. Because you are likely using email with your domain already, we recommend using a subdomain at Mailgun, such as
  2. Click Add Domain.
  3. Add the DNS entries that are provided.  
    If you will be receiving emails with Mailgun rather than your own direct email, change the MX records as described in the optional section on the page.

  4. After you add the records, click Continue to Domain Overview.

View domain information

The Domain Information page displays the information that you will use to set up Mailgun with your domain. It also displays the simple SMTP settings for your Mailgun account, for when you want to use a basic SMTP form.

Integrate with WordPress 

  1. Install the Mailgun for WordPress plug-in from
  2. In WordPress, go to Settings > Mailgun.

  3. To use HTTP, perform the following steps:
    1. Leave Use HTTP API set to Yes.
    2. Log in to the Cloud Control Panel and select Rackspace Cloud > Mailgun.

      Your main Mailgun Control Panel displays your API key and custom domains.

    3. Back on the Mailgun plug-in settings page,  enter the API key for the custom domain that you are using, and enter an optional tag for tracking purposes.
  4. To use SMTP, perform the following steps:
    1. Set Use HTTP API to No.
    2. Enter the SMTP credentials that you received earlier.

  5. Click Save Changes.
  6. Click Test Configuration to verify that the configuration works.

    Your WordPress site is now set up to use Mailgun for system emails such as password resets, login tracking, or anything else WordPress is set to use email for.

Use Mailgun for PHP mail

Using the SMTP settings from the preceding setup steps, you can set up a simple PHP SMTP script, as described in the article How do I test PHP functionality?.

Enter your SMTP credentials and test the page.

Use Mailgun in ASP

Using the SMTP settings from the preceding setup steps, you can set up 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() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) 
{ try { MailMessage mail = new MailMessage(); 
SmtpClient SmtpServer = new SmtpClient(""); 
mail.From = new MailAddress(""); 
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; SmtpServer.Send(mail); MessageBox.Show("mail Send"); 
catch (Exception ex) 
{ MessageBox.Show(ex.ToString()); } } } } 

 Enter your SMTP credentials and test the page. 

© 2015 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

See license specifics and DISCLAIMER