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 at https://mycloud.rackspace.com using your Rackspace account credentials..
  2. Click the More menu in the top-right of the panel, and click the Mailgun link.


    Your account synchronizes with Mailgun, and the Mailgun website 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 mg.domain.com.
  2. Click Add Domain.
  3. Add the DNS entries that are provided.  
    If you will be receiving emails with Mailgun rather than your own 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 http://wordpress.org/plugins/mailgun/. Then, in Wordpress, go to Settings > Mailgun.

  2. To use HTTP, perform the following steps:
    1. Leave Use HTTP API set to Yes.
    2. Log in to mycloud.rackspace.com and select More > Mailgun.

      In your main Mailgun control panel, you will see 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 an optional tag for tracking purposes.
  3. To use SMTP, perform the following steps:
    1. Set Use HTTP API to No.
    2. Enter the SMTP credentials that you received earlier.

  4. Click Save Changes.
  5. 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("smtp.mailgun.org"); 
mail.From = new MailAddress("your_email_address@domain.com"); 
mail.To.Add("to_address"); 
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. 



Was this content helpful?




© 2011-2013 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