How to set up a mailchimp smtp server

How to set up a mailchimp smtp server

Introduction: Why Use Mailchimp’s Transactional Email (formerly Mandrill)?

While Mailchimp is renowned for its marketing automation and email campaigns, its transactional email service (previously known as Mandrill, now integrated into Mailchimp as a paid add-on) offers a robust and reliable solution for sending individual, triggered emails. These emails are crucial for user interactions, such as password resets, order confirmations, shipping notifications, and other personalized messages. Using Mailchimp’s SMTP server can improve deliverability, provide detailed analytics, and streamline your email infrastructure, especially if you’re already invested in the Mailchimp ecosystem. This article will guide you through the process of setting up and configuring Mailchimp’s SMTP server.

Understanding the Prerequisites

Before diving into the setup process, ensure you have the following in place:

  • A Paid Mailchimp Account: Transactional email is not included in Mailchimp’s free plan. You need to subscribe to a paid plan that includes the Transactional Email add-on.
  • A Verified Domain: You need to verify your sending domain within your Mailchimp account to prove ownership and improve deliverability.
  • DNS Record Access: You will need access to your domain’s DNS records to configure SPF and DKIM settings, which are essential for authentication and deliverability.

Enabling Transactional Email (formerly Mandrill) in Mailchimp

Since Mandrill is now integrated within Mailchimp, the process has become simplified, although you need to purchase it as an add-on.

  1. Log in to your Mailchimp account.
  2. Navigate to the “Integrations” section. Look for something similar to “Integrations” in your profile or settings menu.
  3. Find the “Transactional Email” integration (it may still be labeled Mandrill in some areas).
  4. Follow the on-screen instructions to purchase and enable the add-on. This will typically involve selecting a plan and providing payment information.

Verifying Your Sending Domain

Domain verification is a crucial step to prove ownership and improve email deliverability. This process involves adding specific DNS records to your domain’s configuration.

  1. In your Mailchimp account, go to the Transactional Email dashboard.
  2. Find the “Domains” section.
  3. Click “Add Domain” and enter the domain you want to use for sending transactional emails.
  4. Mailchimp will provide you with a set of DNS records (TXT, MX, and CNAME) that you need to add to your domain’s DNS settings.

Here’s a breakdown of the common DNS records you’ll need to add:

  • TXT Record (SPF): This record authorizes Mailchimp to send emails on behalf of your domain, preventing spammers from forging your address.
  • DKIM Record: This record adds a digital signature to your emails, verifying their authenticity and preventing tampering.
  • MX Record: This record specifies the mail server responsible for receiving emails for your domain. While less critical for transactional emails sent *from* your domain, it’s generally good practice to have correctly configured MX records.

Consult your domain registrar’s documentation for instructions on how to add DNS records. The exact steps will vary depending on your provider (e.g., GoDaddy, Namecheap, Cloudflare).

Once you’ve added the DNS records, return to Mailchimp and click “Verify.” It may take up to 48 hours for the DNS changes to propagate and for Mailchimp to verify your domain.

Locating Your Mailchimp SMTP Credentials

After verifying your domain and enabling the Transactional Email add-on, you can find your SMTP credentials. These credentials are used to configure your application or script to send emails through Mailchimp’s servers.

  1. Go to the Transactional Email dashboard in your Mailchimp account.
  2. Look for a section labeled “SMTP & API Info” or similar.
  3. You will find the following information:
    • SMTP Host: This is the server address you need to connect to (e.g., smtp.mandrillapp.com or smtp.mailchimp.com).
    • SMTP Port: The port number used for the SMTP connection (typically 587 for TLS or 465 for SSL).
    • Username: Your Mailchimp username or a specific SMTP username provided by Mailchimp.
    • Password: An API key generated specifically for SMTP authentication.

Make sure to keep your API key secure and do not share it publicly. Treat it like a password.

Configuring Your Application to Use Mailchimp SMTP

The process of configuring your application to use Mailchimp’s SMTP server will depend on the programming language and framework you’re using. Here are some general guidelines and examples:

Using PHP

You can use the PHP `mail()` function or a dedicated library like PHPMailer to send emails via SMTP.


<?php
require 'vendor/autoload.php'; // If using PHPMailer

use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerSMTP;
use PHPMailerPHPMailerException;

$mail = new PHPMailer(true);

try {
    //Server settings
    $mail->SMTPDebug = SMTP::DEBUG_OFF;                      //Enable verbose debug output
    $mail->isSMTP();                                            //Send using SMTP
    $mail->Host       = 'smtp.mailchimp.com';                     //Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
    $mail->Username   = 'your_mailchimp_username';                     //SMTP username
    $mail->Password   = 'your_mailchimp_api_key';                               //SMTP password
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;            //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
    $mail->Port       = 587;                                    //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

    //Recipients
    $mail->setFrom('from@example.com', 'Mailer');
    $mail->addAddress('joe@example.net', 'Joe User');     //Add a recipient

    //Content
    $mail->isHTML(true);                                  //Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body in bold!';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}

Remember to replace placeholders like `your_mailchimp_username`, `your_mailchimp_api_key`, `from@example.com`, and `joe@example.net` with your actual credentials and email addresses.

Using Python

You can use the `smtplib` library in Python to send emails via SMTP.


import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

sender_email = "from@example.com"
receiver_email = "to@example.com"
password = "your_mailchimp_api_key"

message = MIMEMultipart("alternative")
message["Subject"] = "multipart test"
message["From"] = sender_email
message["To"] = receiver_email

# Create the plain-text and HTML version of your message
text = """
Hi,
How are you?
Real Python has many great tutorials:
www.realpython.com"""
html = """
<html>
  <body>
    <p>Hi,<br>
       How are you?<br>
       <a href="http://www.realpython.com">Real Python</a>
       has many great tutorials.</p>
  </body>
</html>
"""

# Turn these into plain/html MIMEText objects
part1 = MIMEText(text, "plain")
part2 = MIMEText(html, "html")

# Add HTML/plain-text parts to MIMEMultipart message
# The email client will try to render the last part first
message.attach(part1)
message.attach(part2)


try:
    with smtplib.SMTP("smtp.mailchimp.com", 587) as server:
        server.starttls()
        server.login("your_mailchimp_username", password)
        server.sendmail(sender_email, receiver_email, message.as_string())
        print("Email sent successfully!")
except Exception as e:
    print(f"Error: {e}")

Again, replace the placeholders with your actual values.

General Considerations

  • Choose the correct port and security protocol (TLS or SSL) based on Mailchimp’s recommendations.
  • Handle exceptions and errors gracefully in your code to provide informative feedback to the user.
  • Implement proper error logging to help troubleshoot any issues with email sending.

Testing Your SMTP Configuration

After configuring your application, it’s crucial to test your SMTP setup to ensure that emails are being sent correctly.

  1. Send a test email from your application to a valid email address.
  2. Check your inbox (and spam folder) to see if the email was received successfully.
  3. Examine the email headers to verify that the email was sent from Mailchimp’s servers and that SPF and DKIM authentication passed.

Mailchimp provides detailed reporting on email delivery, opens, clicks, and bounces. Use these reports to monitor the performance of your transactional emails and identify any potential issues.

Troubleshooting Common Issues

Here are some common issues you might encounter when setting up and using Mailchimp’s SMTP server:

  • Authentication Errors: Double-check your username and API key. Ensure that the API key has the necessary permissions.
  • Connection Errors: Verify that your application can connect to Mailchimp’s SMTP server on the specified port. Check your firewall settings.
  • Deliverability Issues: Ensure that your domain is verified and that SPF and DKIM records are configured correctly. Monitor your bounce rate and spam complaints.

Conclusion

Setting up Mailchimp’s transactional email (formerly Mandrill) SMTP server provides a reliable and scalable solution for sending individual emails. By following the steps outlined in this guide, you can integrate Mailchimp’s powerful email infrastructure into your applications and improve the deliverability and performance of your transactional emails. Remember to regularly monitor your email performance and address any issues promptly to maintain a positive sender reputation.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top