In the step by step guide at: https://github.com/smsohan/MvcMailer/wiki/MvcMailer-Step-by-Step-Guide
It is stated that the .net mail lib is used (System.Net.Mail).
In medical transactions, there is a need to change servers based on country region and record if the mail message was sent with status.
.net mail lib will do this but I have trouble understanding where to put the following code pieces when Using MVC Mailer:
.net Mail Lib-->
SmtpClient client = new SmtpClient(server, port);
client.credentials = CredentialCache.DefaultNetworkCredentials;
MVC Mailer-->
public ActionResult SendWelcomeMessage()
{
UserMailer.SmtpClient(server, port);
UserMailer.credentials = CredentialCache.DefaultNetworkCredentials;
UserMailer.Welcome().SendAsync();
return RedirectToAction("Index");
}
static bool mailSent = false;
private static void SendCompletedCallback(object sender, AsyncCompletedEventArgs e)
{
// Get the unique identifier for this asynchronous operation.
String token = (string) e.UserState;
if (e.Cancelled)
{
Console.WriteLine("[{0}] Send canceled.", token);
}
if (e.Error != null)
{
Console.WriteLine("[{0}] {1}", token, e.Error.ToString());
} else
{
Console.WriteLine("Message sent.");
}
mailSent = true;
}
if MailSent is false, then write to Critical Log Error.
I am not sure where the client setting for .net setting should go. Should they go in the controller as I have done above or in the Mailer method.
Thanks for any advice.
Regards, Vic