You need an internet host without SMTP blocked like your home internet service. The idea is to use it as a relay on a different port like 225 which isn’t blocked.
Setup your localhost to deliver your email.
Steps:
Step 1: Get a Gmail id and password
Step 2: Login in and switch to root using: sudo su -
Step 3: Run the below commands (assuming debian packages like ubuntu):
apt-get update
apt-get install sendmail sasl2-bin mailutils
Step 4: Create an authentication file
cd /etc/mail
mkdir -m 700 authinfo
cd authinfo/
emacs (or vi or vim or nano, etc) gmail
add the below content to the file:
AuthInfo: "U:root" "I:your-gmail-id@gmail.com" "P:your-password"
Edit using your gmail id and password
Step 5: Create a hash map of the file:
makemap hash gmail < gmail
Step 6: Go to /etc/mail and open sendmail.mc
Add the following lines to sendmail.mc file right above MAILER_DEFINITIONS:
#GMail settings:
define(`SMART_HOST',`[smtp.gmail.com]')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
define(`confAUTH_OPTIONS', `A p')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash -o /etc/mail/authinfo/gmail.db')dnl
Step 7: Run the two commands from /etc/mail
make
/etc/init.d/sendmail reload
Step 8: Now open https://www.google.com/settings/security/lesssecureapps
and Allow less secure apps: ON
Step 9: Verify a test mail using
echo "Test" | mail -s "This is a test" some-id@some-domain.com
Setup a port forwarding on your router. I used port 225 on the outside to port 25 on the internal machine running sendmail.
Next edit /etc/mail/sendmail.mc and change:
< DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
> DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp')dnl
removing the , Addr=127.0.0.1
This will open up port 25 on your sendmail server.
We’re still not done yet because relaying is not allowed. Add a file named /etc/mail/relay-domains. The contents of the file should contain every domain, one per line of each domain that you want to relay.
In /etc/mail as root re-run the following commands:
make
/etc/init.d/sendmail reload
Now from your Linode-hosted domain, you may connect to your sendmail server on the outside port, unauthenticated and it will be relayed onto the gmail servers authenticated.
Update:
If you are using WordPress follow this guide: