Solution to some email related issues recently posted on the forum (SMTP account problems, removing "Expert Adviser", HTML formatted emails)

 

Following some recent email related posts here is a method I found that enables:

  1. Sending emails without a SMTP account.
  2. Removing "Expert Adviser" from the 'From' field.
  3. Sending HTML formatted emails.

The method uses a freeware SMTP relay client I have been using for a few months: mini-Relay v0.9.77d by NetVicious.


1. Sending emails without a SMTP account :

  1. Make sure 'Enable' is ticked.
  2. Under SMTP server put 127.0.0.1
  3. SMTP login/password can remain blank.
  4. Fill the 'From' and 'To' fields with emails ('From' can have whatever, 'To' is the target email).
  • Press the 'Test' button, the result can be seen in the journal.
  • Go to your email's inbox. If you did not receive the message then it's probably in the Spam folder. In Gmail u can do the following (don't know about other mail services...):
  1. Go to Spam, select the email and click 'Not spam'.
  2. Add the email u put in the 'From' field to your contacts (this will insure future MT4 emails will not go to spam).


That's it! Try using SendMail() from any of your experts and enjoy. A word of caution - try to limit the number of emails sent per day to a reasonable amount, otherwise your email provider will tag you as a spammer and decline emails from your IP! If this happens, you will be able to see this in the mini-Relay log... (make sure that 'Create log file' is ticked in mini-Relay > Configuration > General Tab).


2. Removing "Expert Adviser" from the 'From' field :

  • mini-Relay > Configuration > Headers Tab. Fill in the following details:


  • Notes:
  1. To remove a header only the name of the header should be added to the 'Remove header' field (without the ':').
  2. The 'From:' field can contain a name as well, such as: Gordon Shumway <example@gordon.com>
  3. More info about email headers: Wiki: MIME (Multipurpose Internet Mail Extension).


3. Sending HTML formatted emails :

  • mini-Relay > Configuration > Headers Tab. Change 'Content-Type' MIME form type 'text/plain' to type 'text/html':


  • Now all we need to do is send emails in HTML format. Example:
int start()
  {
//----
   string text = "<html>";
   text = StringConcatenate(text,"<body><h1>Hello, World!</h1>");
   text = StringConcatenate(text,"<p>HTML formated email Sent from MT4.</p></body></html>");
//----
   SendMail("Hello, World!",text);
//----
   return(0);
  }


Notes:

  • Some security software report mini-Relay as malware, since it is often used by spammers. I can verify that it's not (but use at your own risk).
  • There's an alternative program called 'Free SMTP Server' (http://www.softstack.com/freesmtp.html) that was recommended a few times on the forum, but it lacks the advanced options in mini-Relay (no header manipulation).
  • mini-Relay allows to remove/add ANY header, so potentially this method might have other interesting uses. If u find any, please share!
  • Specifically, if anybody can figure out a way to send attachments with a combination of MQL4 and mini-Relay, but without using any external dll's, then PLEASE post your finding!





 
gordon:

Following some recent email related posts here is a method I found that enables: [...]

I've got a DLL which will do multiple recipients, HTML messages, attached files, and also handles servers such as Gmail which require SSL. Its major disadvantage is that it can't read the MT4 email settings; an EA (or script) has to pass it the full parameters of the message to send and the server to use.


Want to try it out?

 
jjc:

I've got a DLL which will do multiple recipients, HTML messages, attached files, and also handles servers such as Gmail which require SSL. Its major disadvantage is that it can't read the MT4 email settings; an EA (or script) has to pass it the full parameters of the message to send and the server to use.


Want to try it out?

Thanks for the offer jjc. I appreciate it. But did u write it yourself or just found it online? Do u have the source code?

I'm asking cause I've had some very bad experience with the DLL's floating around in the forums. The majority are just badly written and it's only a matter of time until they crash the Terminal. So I have decided a few months back not to use any unknown "black-box" DLL's any more. The risk is just to high. The built-in email/ftp clients, although over-simplified and limited, are 100% reliable so far.

 
gordon:

But did u write it yourself [...]

Yes. Send me a PM if interested.

 
this is great
 

Hi! Is any way I can speed up the mailing process? It takes around 5 minutes to send the message.

 
alex198555:

Hi! Is any way I can speed up the mailing process? It takes around 5 minutes to send the message.

As you can see from your own screen-shot, there were quite a few errors during sending. You can google the error numbers for information on how to overcome this... (these are all email related errors and have nothing to do with MQL or trading).

Alternatively, I recommend ditching this method and using the one described here -> https://www.mql5.com/en/forum/124238.

 
Hello. My metatrader 4 can't connect to 127.0.0.1. When I press Test Button in journal is massage " Mail: error connecting to 127.0.0.1. " mini-relay is running, also I tried freesmtp program. I am Windows 7. May this be problem? how can I fix this problem?
 
This forum is about MQL4 . . . not Mail Servers, or other mail relay apps . . .
 
yes, I want to use email send function in MQL4. For this I must configure MT4 like above is said. But it isn't working. And I wonder why. I did everything like above but I got error. If you can help me. tell me what the problem is
 
Pay for a decent email service and use that . . . problem solved.
Reason: