Howto/20230921 Use a cheap VPS to bypass ISP blocking of port 25 to postfix mail server: Difference between revisions

From Interpause
Jump to navigationJump to search
Line 8: Line 8:
* For outbound emails, use the ISP's smtp server to send emails.
* For outbound emails, use the ISP's smtp server to send emails.
* For inbound emails, use a cheap VPS whose port 25 is open to receive and then forward emails to the main mail server on external port 2025 and internal port 25 (not blocked by ISP). We already have a cheap VPS for our OpenVPN server with racknerd that costs 11USD/year so, for us, there is no extra cost to setup this mail forwarder. Our solution is based on the following guide to setup a backup MX: https://www.howtoforge.com/postfix_backup_mx
* For inbound emails, use a cheap VPS whose port 25 is open to receive and then forward emails to the main mail server on external port 2025 and internal port 25 (not blocked by ISP). We already have a cheap VPS for our OpenVPN server with racknerd that costs 11USD/year so, for us, there is no extra cost to setup this mail forwarder. Our solution is based on the following guide to setup a backup MX: https://www.howtoforge.com/postfix_backup_mx
=== Prerequesites ===
* You already have a working email server configured with postfix, but port 25 is completely blocked
* You have rented a cheap VPS and have installed postfix using the default configuration
* For us, the main mail server is located at mail1.interpause.com, the cheap VPS is at mail2.interpause.com, and our ISP's smtp server is smtp.ebox.com. Be sure to switch these for your own domain addresses.


=== Steps ===
=== Steps ===


# Setup MX records on domain provider to point to VPS (mail2.interpause.com)
# Setup MX records on domain provider to point to VPS
#* For namecheap, it looks like this:  
#* For namecheap, it looks like this:  
[[File:NamecheapMXRecord.gif | 800px]]
[[File:NamecheapMXRecord.gif | 800px]]


# Setup main mail server (mail1.interpause.com)
# Setup mail1.interpause.com to use the ISP's smtp server for inbound emails and accept connections from the VPS for inbound emails
 
<pre>
myhostname = mail1.interpause.com
mydestination = mail1.interpause.com, localhost, localhost.localdomain
relayhost = smtp.ebox.ca
</pre>


# Setup main mail server (mail1.interpause.com) to allow connections from mail2.interpause.com
# Setup mail2.interpause.com

Revision as of 11:08, 21 September 2023

Disclaimer

My Howtos are mainly for me to document the steps required in case I ever have to re-do them again. Hopefully they will help other system admins out there, but I regret that this is not my primary objective.

Problem

We just switched to a new Internet Service Provider (ISP) that blocks port 25, both ways, making us no longer able to send or receive emails.

Solution

  • For outbound emails, use the ISP's smtp server to send emails.
  • For inbound emails, use a cheap VPS whose port 25 is open to receive and then forward emails to the main mail server on external port 2025 and internal port 25 (not blocked by ISP). We already have a cheap VPS for our OpenVPN server with racknerd that costs 11USD/year so, for us, there is no extra cost to setup this mail forwarder. Our solution is based on the following guide to setup a backup MX: https://www.howtoforge.com/postfix_backup_mx

Prerequesites

  • You already have a working email server configured with postfix, but port 25 is completely blocked
  • You have rented a cheap VPS and have installed postfix using the default configuration
  • For us, the main mail server is located at mail1.interpause.com, the cheap VPS is at mail2.interpause.com, and our ISP's smtp server is smtp.ebox.com. Be sure to switch these for your own domain addresses.

Steps

  1. Setup MX records on domain provider to point to VPS
    • For namecheap, it looks like this:

NamecheapMXRecord.gif

  1. Setup mail1.interpause.com to use the ISP's smtp server for inbound emails and accept connections from the VPS for inbound emails
myhostname = mail1.interpause.com
mydestination = mail1.interpause.com, localhost, localhost.localdomain
relayhost = smtp.ebox.ca
  1. Setup mail2.interpause.com