Email notifications
Email notifications
19 Feb 2024, 14:14
I replied to a previous post about email notifications, but never got any reply, so thought I'd start a new one, since I can't seem to get this working. I've been testing it by using it on a live demo account. I don't expect it to work via back-testing as documented.
I've tried using the email settings in ctrader and also creating a smtp client in c#, but neither works for me.
I've tried my Outlook, Icloud, Gmail and created a new Yahoo account, using their email addresses and smtp server names. I tried both the 465 and 587 ports and I always get ‘Authentication with SMTP server failed’ or ‘GeneralFailure’ status code in c# and ‘Failure sending mail’.
My code below with the current yahoo server code and user/pass removed. Any help would be appreciated.
try
{
Print("C# - Attempting to email...");
var smtpClient = new SmtpClient()
{
Host = "smtp.mail.yahoo.com", // smtp-mail.outlook.com. smtp.office365.com
Port = 465, // 465 / 587
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("***", "***")
};
var mailMessage = new MailMessage
{
From = new MailAddress(EmailAddressFrom),
Subject = "Hello from Bot",
Body = "Hello, this is a test email from C#."
};
mailMessage.To.Add(EmailAddressTo);
smtpClient.Send(mailMessage);
smtpClient.SendCompleted += SendCompleted;
}
catch (SmtpException ex)
{
throw new ApplicationException
($"C# - SmtpException has occured. Status code: {ex.StatusCode}. Msg: {ex.Message}" );
}
Replies
ashtwentythree
20 Feb 2024, 11:59
RE: Email notifications
PanagiotisCharalampous said:
Hi there,
Have you set your access rights to Full Access?
Best regards,
Panagiotis
Hi Panagiotis,
Yea, I have. It's been set to that for a while.
@ashtwentythree
ashtwentythree
15 Mar 2024, 13:10
( Updated at: 16 Mar 2024, 10:58 )
RE: RE: Email notifications
ashtwentythree said:
PanagiotisCharalampous said:
Hi there,
Have you set your access rights to Full Access?
Best regards,
Panagiotis
Hi Panagiotis,
Yea, I have. It's been set to that for a while.
Just to give an update on this, in case anyone else has the issue.
I went back to using Gmail and created an App Password. I used that instead of my own password and it worked right away. phew
Go here for more info on App Passwords
Sign in with app passwords - Google Account Help
@ashtwentythree
PanagiotisCharalampous
20 Feb 2024, 06:54
Hi there,
Have you set your access rights to Full Access?
Best regards,
Panagiotis
@PanagiotisCharalampous