Emails on Digital Ocean with Flexible IPs

Lecture de 2 minutes

UPDATE: Newly created Droplets don't allow usage of port 25 anymore. This article only apply to older Droplets.

When using Digital Ocean and Flexible IPs with Plesk, outbonds emails might not be sending properly.

This is an issue related to the IP address used by postfix.

To solve it, you need to change the default IP address capable to connect to the external mail servers:

Log in to Plesk GUI > Tools & Settings > Mail Server Settings > Outgoing mail mode > Send from the specified IP addresses. Then, select the valid IP address.

The following script will tell you which IP is the right one :

MAILSERVER="173.194.203.26"; RE="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"; if [[ $MAILSERVER =~ ^${RE}$ ]]; then for IP in `ip a | egrep -o ${RE} | egrep -v 255$\|^127\|0.0.0.0 | sort | uniq`; do echo -e "\nChecking connection: $IP -> $MAILSERVER:25"; nc -z -w5 -s $IP $MAILSERVER 25 &>/dev/null; err=`echo $?`; if [ $err -eq 0 ]; then echo -e "Success: Connection works"; elif [ $err -eq 1 ]; then echo -e "Error: Connection failed"; elif [ $err -eq 127 ]; then echo -e "\nError: Install Ncat package"; kill -INT $$; else echo -e "\nError: Unexpected error code"; kill -INT $$; fi; done; else echo -e "\nError: The value is not an IP address"; fi

Where MAILSERVER parameter is the external mail IP address that cannot be reached according to the error logs

Refer to the solution for more informations.

Documentation

Here is the solution

Mail messages are stuck in mail queue after changing Outgoing mail IP on Plesk server

Here is someone else with the same issue

Daniel Pereyra - Emails are not sent from a Plesk server with the errors "25: Connection timed out"

Here is how to force postfix to use a specific IP adress for outgoing emails

Changing Postfix Outbound IP Address