Does sending of emails actually work in cTrader Automate?

Created at 28 Mar 2022, 16:19
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
FI

firemyst

Joined 26.03.2019

Does sending of emails actually work in cTrader Automate?
28 Mar 2022, 16:19


Hi everyone:

I've been wanting to set up indicators to send email notifications.

I've followed the instructions here:

https://help.ctrader.com/ctrader-automate/email_notifications

The indicator code I have for testing, which should send an email every time I adjust the settings:

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Test : Indicator
    {
        [Parameter(DefaultValue = 10)]
        public int Period { get; set; }

        protected override void Initialize()
        {
            Notifications.SendEmail("myEmailAddress@mail.com", "myEmailAddress@yahoo.com", "This is the subject", "and here is the body");
        }

        public override void Calculate(int index)
        {
        }

    }
}

My settings in cTrader when I try sending emails either through mail.com or yahoo.com:

https://www.lifewire.com/what-are-mail-com-smtp-settings-1170500, https://getmailspring.com/setup/access-yahoo-com-via-imap-smtp, https://www.saleshandy.com/smtp/mail-com-smtp-settings/, and multiple other websites.

No emails come through anywhere; not in a "spam" folder, not in my "inbox", not in my "Trash", nowhere.

No errors are thrown in the indicator and no exceptions are thrown when I debug in visual studio.

My question is -- does sending emails via SMTP through cTrader API work?

Does anyone have an actual working example?

@Spotware?

Thank you.

 


@firemyst
Replies

amusleh
29 Mar 2022, 10:55

Hi,

It does work, but it depends on the email service you are using, some services doesn't allow old SMTP authentication anymore like Gmail as it causes security issues.

I tested it on my own email server and it works fine.

cTrader automate API just provide a wrapper over .NET SMTP API to make it easier.

 


@amusleh

firemyst
29 Mar 2022, 11:28

RE:

amusleh said:

Hi,

It does work, but it depends on the email service you are using, some services doesn't allow old SMTP authentication anymore like Gmail as it causes security issues.

I tested it on my own email server and it works fine.

cTrader automate API just provide a wrapper over .NET SMTP API to make it easier.

 

 

So it definitely works with gmail? I can set up a test gmail account, keep the same indicator code (except changing the email addresses as appropriate), and all should work "as is"?

Also, what do you mean by "old smtp authentication"? All the links I found, and posted in my original post, explain how to set up SMTP authentication with the parameters required by cTrader.

Thank you.


@firemyst

amusleh
29 Mar 2022, 13:56

RE: RE:

firemyst said:

amusleh said:

Hi,

It does work, but it depends on the email service you are using, some services doesn't allow old SMTP authentication anymore like Gmail as it causes security issues.

I tested it on my own email server and it works fine.

cTrader automate API just provide a wrapper over .NET SMTP API to make it easier.

 

 

So it definitely works with gmail? I can set up a test gmail account, keep the same indicator code (except changing the email addresses as appropriate), and all should work "as is"?

Also, what do you mean by "old smtp authentication"? All the links I found, and posted in my original post, explain how to set up SMTP authentication with the parameters required by cTrader.

Thank you.

Hi,

No, it doesn't work with Gmail as far as I know, there was an option in Gmail settings that would allow SMPT authentication but I'm not sure if it's still possible or not.

As I said on my previous post, it all depends on your email provider, if they allow SMPT authentication then it should work fine without any issue, if they are using some other way for authentication then it will not work.


@amusleh

Xammo
01 Sep 2022, 19:23

Just got back to using email notifications (that had worked for ages with gmail) and realised they weren't working/came across this thread

Managed to get them working no problems using an outlook account - nothing special other than setting the sending/receiving email addresses in the bot code to same email address and entering all the outlook SMTP details as found on the web - probably don't have 2FA set on the account either as is purely for notifications but haven't checked - good luck anyone who is trying


@Xammo

PanagiotisCharalampous
05 Sep 2022, 10:24

Hi all,

ClickAlgo has a nice guide about this issue. Check below.

https://clickalgo.com/how-to-fix-ctrader-email

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

ThomasSparrow
07 Aug 2023, 14:59 ( Updated at: 20 Aug 2023, 08:39 )

RE: Does sending of emails actually work in cTrader Automate?

Yes i try do this, is ok only that i can send only string message, for check error try us try catch, for get error:

try
            {
                Notifications.SendEmail("myemail@hotmail.com", "myemail@gmail.com", "My Trading", "This is a message: " + ko.ToString());
            }
            catch (Exception e)
            {
                Print(e);
            }

 

another think is check if with you mail provider you can send emails by smtp authentication. for example google you use only imap. but i test with my hotmail account is work perfect.


@ThomasSparrow