SendMail server time vs. local time

 

Hi there,

I'm using SendMail() to send out emails when some of my indicator calculation values have changed. I noticed that SendMail uses the server date/time for sending out emails. This is kind of confusing because my server time is 2 hour ahead.

I.e. the indicator sends out an email at 8:00 am (local time) but my email program shows 10:00 am. Even if this time is in the future. So it seems the server time is some kind of hard coded into the email.

Is there any way to change this?

You can easily try it if you just send a test email from the options->email dialog and your server time and local time does not match.

Documentation on MQL5: Language Basics / Functions / Event Handling Functions
Documentation on MQL5: Language Basics / Functions / Event Handling Functions
  • www.mql5.com
Event Handling Functions - Functions - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Timo Kosiol:

Hi there,

I'm using SendMail() to send out emails when some of my indicator calculation values have changed. I noticed that SendMail uses the server date/time for sending out emails. This is kind of confusing because my server time is 2 hour ahead.

I.e. the indicator sends out an email at 8:00 am (local time) but my email program shows 10:00 am. Even if this time is in the future. So it seems the server time is some kind of hard coded into the email.

Is there any way to change this?

You can easy try it if you just send a test email from the options->email dialog and your server time and local time does not match.

I have just written two articles about time:

https://www.mql5.com/en/articles/9926

https://www.mql5.com/en/articles/9929

Dealing with Time (Part 2): The Functions
Dealing with Time (Part 2): The Functions
  • www.mql5.com
Determing the broker offset and GMT automatically. Instead of asking the support of your broker, from whom you will probably receive an insufficient answer (who would be willing to explain a missing hour), we simply look ourselves how they time their prices in the weeks of the time changes — but not cumbersome by hand, we let a program do it — why do we have a PC after all.
 
Carl Schreiber #:

I have just written two articles about time:

https://www.mql5.com/en/articles/9926

https://www.mql5.com/en/articles/9929

Hi Carl,

thanks for your reply. Very useful articles.

I'm aware of those date/time "issues" and developed some technics and workarounds myself to deal with it. Bu it does not help with my SendMail() problem. Because SendMail creates the email header by itself and as it seems I have no option to set the email date/time manually. Or am I missing something?

 
Timo Kosiol #:

Hi Carl,

... Because SendMail creates the email header by itself and as it seems I have no option to set the email date/time manually. Or am I missing something?

I guess you are right. You only can write the relevant time in the reference and/or the body of the email.