How to forward all email sent to my domain, to my gmail account?

  • Posted on September 5, 2023
  • Email
  • erelAsked by erel

I have a domain name, which is handled by DigitalOcean DNS. I want each email sent to, to arrive at my gmail mailbox at I went to my DNS page, to the MX tab, and clicked “Add Gmail MX records”, which added 5 MX records. But, I did not find anywhere a place to enter the target gmail mailbox.

How can I set-up my DNS so that all email sent to arrives at

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
September 5, 2023
Accepted Answer

Hi there Erel,

In your case you will have to use a combination of MX records (which direct where emails sent to your domain should go) and email forwarding rules (which specify which mailbox the email should end up in).

The MX records you added from DigitalOcean would only tell the world that Google is the handler of the emails for your domain, but you need more configurations to direct emails to a specific Gmail account.

What you would need to do is:

1. Set Up MX Records:

You’ve already done this step. By adding the Gmail MX records, you’re instructing that emails sent to should be routed through Google’s email servers.

2. Set Up Email Forwarding:

You can’t directly set up email forwarding through DNS records. Instead, you need an intermediary service to capture the email and then forward it to your Gmail address.

There are a couple of ways to handle this:

Using DigitalOcean or another service:

  1. Setup a Mail Server: If you don’t have a mail server already, you’ll need to set up one for There are solutions like Postfix, Exim, etc., which can handle this. Setting up a mail server can be complex, so if you’re not familiar with this, it might be a challenging step, here is a good article that covers why you might not want to run your own email service:

  2. Email Forwarding: Once your mail server is up and running, you’ll set up a rule to forward emails from to

Using a third-party email forwarding service:

Instead of setting up a mail server yourself, you can use third-party email forwarding services. Services like ImprovMX, ForwardMX, or Pobox allow you to forward emails from your domain to your Gmail account without needing to set up a mail server.

For most of these services:

  1. You’ll sign up and specify that emails to should be forwarded to
  2. They might provide you with specific MX records to set up on your DigitalOcean DNS. If so, replace the Gmail MX records you added with the ones provided by the email forwarding service.

3. Handling Gmail Side:

Once you’ve set up email forwarding, emails will be sent to your Gmail. However, Google might classify these forwarded emails as spam since they’re relayed through different servers.

  1. Create a Filter: To avoid emails being marked as spam, you might want to set up a filter in Gmail. Go to Gmail settings → Filters and Blocked Addresses → Create a new filter. You can set the filter to recognize emails sent to and then mark them as “Not spam”.

  2. Send As: If you want to send emails from Gmail as, you can set this up in Gmail settings under “Accounts and Import” → “Send mail as” → “Add another email address”.

An alternative option is to use Google’s business email service which let’s you use a custom domain name:

Hope that this helps!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel