AHdark

AHdark Blog

Senior high school student with a deep passion for coding. Driven by a love for problem-solving, I’m diving into algorithms while honing my skills in TypeScript, Rust, and Golang.
telegram
tg_channel
twitter
github

Using Mailgun for email services

Recently, I have gradually replaced almost all the email services used by my services with Mailgun. In this article, I will discuss the reasons behind this decision and the specific steps I took.

Before deciding to use Mailgun, I had made various attempts with SMTP email sending.

Previous Options#

Alibaba/Tencent Enterprise Email (Domestic)#

When I was still working at YuanYun, we relied on Alibaba Cloud's enterprise email for corporate affairs.

The enterprise email has both sending and receiving functions, with good stability, but the price is relatively high. For personal services, purchasing five accounts starting at 600 yuan per year for an enterprise email seems unnecessary.
Services like Tencent's enterprise email rely too much on WeChat for business, which is overly complicated and troublesome for individuals, and the support for the Exchange protocol is inadequate.

Therefore, I abandoned this idea.

Alibaba/Tencent Email Sending#

During my time at YuanYun, I used Alibaba Cloud's email sending for notifications. The benefits include high stability and support for multiple domains and users.
However, it only provided email sending services and did not support email receiving or forwarding, so I abandoned this solution after some time.

ahdark.com used Alibaba Cloud email sending for notifications for a long time, with a separate domain notify.ahdark.com.

Microsoft Exchange Enterprise Email#

Microsoft Exchange is a highly customizable solution that relies on Microsoft enterprise services. Using the developer E5 package and the basic business package allows free use of this service, with costs manageable within a reasonable range. Not only that, it also provides both sending and receiving email functions, so my domain email service does not need to be set up separately.

However, the downside is its high dependence on Microsoft's enterprise user services, and the difficulty of using login.live.com is well-known. Additionally, this solution cannot be linked to the Mail application on Windows 10 and Windows 11 due to the servers being located abroad, making it quite difficult to receive emails at the system level.

Therefore, after using this solution for a while, I gradually switched away from it, now only retaining sourcegcdn.com and sourcegcdn.net with this solution.

Forward Mail#

This service provides email forwarding for domain emails, with limited but effective functions. When using Alibaba Cloud email sending for sending emails at ahdark.com, I also used the Forward Mail service for receiving emails. I forwarded emails from the corresponding account name to ahdark@outlook.com (my main email) to receive emails from the domain email. However, since it did not provide sending services, I had to use a proxy for sending. Subsequently, I replaced this service and Alibaba Cloud email sending with Mailgun, so it was discontinued.

Mailgun#

Mailgun is a company that provides services specifically for email, with its main entity being Mailgun Technologies, Inc., and its service site located at https://www.mailgun.com.
Its products include email sending, forwarding, and tracking. It supports two email sending methods: SMTP and API; two email forwarding methods: WebHook and Forward; and effective tracking methods.

Due to its good reputation and high-quality service, I started using this service recently.

mailgun

Registration#

Registering for Mailgun requires the following information:

  • An existing email address
  • A mobile number (to receive a verification code)
  • A credit card number (for verification only)

I registered using my MasterCard virtual card and a virtual mobile number.

Plans#

image

image

After registration, a 30-day trial period called the Foundation Trial plan will be activated. During this phase, you can enjoy the following services:

  • 5000 emails sent/received per month
  • 5 days of log tracking
  • 24/7 service support

After 30 days, it will automatically convert to the Foundation 50k plan at $35/month, which allows for 50k emails sent/received per month.

After registration, you can downgrade to the pay-as-you-go Flex plan on the Billing page. This plan has no fixed monthly fee and offers a free quota of 1000 emails sent/received per month and an additional 1000 emails sent/received for $1 in a pay-as-you-go model.

Adding Domains#

After registration, you can add domains in the backend.

image

Mailgun will provide a Sandbox domain for testing, and you can also add your own domain.

Adding a domain requires adding DNS records:

Record NameRecord TypeExample Record Value
@TXTv=spf1 include:mailgun.org ~all
mx._domainkeyTXTk=rsa; p=<string>
@MX10 mxa.mailgun.org
@MX10 mxb.mailgun.org

Please refer to the instructions when adding.

SMTP Sending#

After adding the domain, you can find the SMTP credentials settings under Sending - Domain Settings - SMTP credentials.

New SMTP credentials

After setting the credentials, you will receive the corresponding account password. You can then log in using the following credentials:

  • SMTP Server: smtp.mailgun.org
  • Port: 25 / 465 (SSL/TLS) / 587
  • Account: no-reply@ahdark.blog
  • Password: <your-password>

Receiving (Forwarding)#

image

You can set up email receiving methods in Receiving, supporting email forwarding and WebHook methods. For specific configuration, please refer to the documentation: https://documentation.mailgun.com/en/latest/user_manual.html#routes

Using Mailgun for Sending Emails in WordPress#

Mailgun has officially created the Mailgun for WordPress plugin, which is also the method I use.

First, you need to generate API credentials in the Mailgun backend, which can be found under Sending - Domain Settings - Sending API keys.

After generating, you can use the domain added by Mailgun and the API Key as login credentials, simply filling them in on the Mailgun plugin settings page in WordPress. Of course, you also need to complete the relevant information.

image

After completing the configuration, you can click save at the bottom, and then click the Test Configuration button to test.

Conclusion#

This concludes the content of this article.

The main reason I did not consider building my own SMTP is due to the instability of sending and receiving emails, and almost all domestic cloud service providers have blocked port 25 or strictly limited the setup of sending servers.

Because of this, the method of building SMTP on domestic servers has basically been shut down, which is why I wrote this article.

In the end, I just hope that email services will not be abused like SMS services, becoming tools for malicious attacks against others.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.