Sending email from Aruba (italian hosting service) from non-aruba hosting server

I have an "old" asp.net /.net 4.6 application.

Until recently it was configured to send mail from gmail, and has always been hosted on OVH.

Then Gmail introduced the control for "less secure" apps and if after a while no mails are sent, disable access to the gmail account.

If I try to use the Aruba mailbox, it doesn't work: it "seems" that Aruba is preventing the sending of email from server other than Aruba, is that true? I find something around, but nothing specific.

Now I would like to reconfigure / re-factor the code so that it is resilient to all of this, and the email always goes out.

Here the code:

private static void MandaMail(int? idQP)
{
string myFrom = ConfigurationManager.AppSettings["mailAccount"];
string myTo = ConfigurationManager.AppSettings["LogMail"];

string myMailBody = "…";
string myMailSubject = "…";

try
{

MailMessage mail = new MailMessage(myFrom, myTo, myMailSubject, myMailBody);
mail.IsBodyHtml = true;

var smtpClient10 = new SmtpClient(ConfigurationManager.AppSettings["mailSMTP"])
{
Port = int.Parse(ConfigurationManager.AppSettings["mailSMTPPort"]),
Credentials = new NetworkCredential(ConfigurationManager.AppSettings["mailAccount"], ConfigurationManager.AppSettings["mailPassword"]),
EnableSsl = true,
};

smtpClient10.UseDefaultCredentials = true;


smtpClient10.Send(mail);

}
catch (Exception myEx)
{

Debug.WriteLine(myEx.Data);
Debug.WriteLine(myEx.Message);
//todo: log;
}

return;
}

In the web.config instead:















host="smtps.aruba.it"
password="myPassword"
port="465"
userName="myspecialcustomerservice@miodominio.it"
defaultCredentials="true"
enableSsl="true"/>




Anyone who has already faced this problem, can you help me? Is the above configuration and code setting correct?

What is the best practice to send mail from an Aruba mailbox on a server other than Aruba? How to configure it so that if in the future they want to move the mailing from a GMAIL box, they just need to change the web.config? Do you use external libraries?

Also, the mailSettings>


What is the best practice to send mail from an Aruba mailbox on a server other than Aruba?


Maybe you should ask to Aruba, and maybe in Italian, as you are posting in English in a French forum of a competing company ...