Setting up SMTP Email Relay using hMailserver for MetaTrader 4 (MT4)
MetaTrader 4 does not support SSL Authentication so need for relay
One of the functions of TX Auto Alert is the ability to send reminders to our students of potential trader opportunities through email.
For this function to work, MetaTrader 4 needs to be set up with the appropriate configurations. There are other solutions which we have detailed posts about.
In this post, we will look at how to use hMailServer as an email relay for MetaTrader 4 (MT4). (Not for non-tech-savvy)
What is hMailServer? Why email relay?
hMailServer is a free e-mail server program for Windows which supports e-mail protocols (IMAP, SMTP and POP3).
An email is a SMTP server configured to allows emails to be sent through it. The reason we need to use email relay is mainly due to MetaTrader 4 does not support SSL Authentication. This impacts primarily Gmail.
How to set up hMailServer for MT4?
Below are some simple steps to set up hMailServer.
Step 1: Download the hMailServer software
- Click on the link below and download the latest production release
Step 2: Install hMailServer software
- After downloading the software, run it and click through the installation process as per the following.
Step 3: Configuring hMailServer
After you have finished installing the program, it will launch automatically. We would now need to configure it. Follow the steps below to complete the configuration.
1 > Select localhost with username Administrator. Check Automatically connect on start-up. Click on Connect.
2 > Upon the first login, you’ll be prompted to key in your password. Enter the password which you used earlier during the installation process (refer to image hMailServer Program Installation -7). Click on save
3 > Open Settings, Select Protocols and Click on SMTP
4 > Key in the necessary SMTP information.
5 > If you’re using Gmail. Key in the following:
- Remote host name: smtp.gmail.com
- Remote TCP/IP port: 465
- Server requires authentication needs to be Checked
- User name: Enter your gmail email address including @gmail.com
- Password: Enter your gmail email login password
- Use SSL needs to be Checked
- Click on Save
6 > For the next setting, you would need the IP address of your computer.
- To find out the IP address of your computer you need to open up the Command Prompt.
- On your keyboard press the Win Key + R. Type in cmd and press enter on your keyboard.
- Alternatively, Click on Start –> Search for Command Prompt then open it.
- In the Command Prompt screen, type in ipconfig and press enter.
- The IP Address of your computer will then be displayed.
7 > On the hMailServer program
- Click on Settings
- Select and open up Advanced
- Click and open up IP Ranges
- Select My Computer
- Key in the IP Address of your computer in the Lower IP and Higher IP.
- Uncheck all the options in Require SMTP Authentication
- Click on Save and Exit
8 > To Start the hMailServer Service,
- Click on Start
- Select All Programs
- Select hMailServer program folder
- Open Service sub-folder
- Click on Start service
Step 4: Configurations and Testing in MetaTrader 4 (Updated Step 4-2 on 19 May 2014)
1 > The corresponding configurations in MetaTrader 4 is as follows.
- Open/Run MetaTrader 4 program
- Ensure the your Terminal is open
- To open Terminal in MetaTrader 4
- Click on View
- Select and Click on Terminal
- Select the Journal tab
2 > In MetaTrader 4, Click on Tools, Select Options and Select the Email tab.
- Enter the following:
- SMTP server: [Your Computer IP Address]:25
- SMTP login: Enter your gmail email address
- SMTP password: Leave it Blank
- From: Enter your gmail email address
- To: Enter the email address where you wish to receive your alerts
3 > Click on Test to check if you are able to send a Test Message. Check in the Journal tab of the Terminal to see if this is successful.
4 > Once done Click on OK
5 > By this time, the configurations and settings for hMailServer is completed. You can check your email to see if you have received a test email.
1 > If you do not receive any emails from the test. Then you would need to find out the problem. To get more information on the problem, we would need a log of the issue.
2 > To set up the logging function in hMailServer:
- Run hMailServer Administration
- Click on Settings, then Select Logging
- Check Enabled to enable logging
- Select to log SMTP
- Click on Save
3 > After, go back to MetaTrader 4 and resend another test message. You can check the logs in hMailServer to see what is the problem.
Common Problems Encountered
- If you’re using hMailServer from a computer which you have not logged into your Email on the web-browser before then Gmail might see this connection as suspicious activity. To resolve this, then just login to your email from that computer once before starting hMailServer service.
- If you’re moving from location to location. Your computer IP Address will be different so you would need to make changes to the IP address used in hMailServer as well as in your MetaTrader 4. To make the changes, you can click on here and follow the steps given which is the same as during your configuration process.