Please I had code to send emails to user when register on our website I did the code but no message was sent and error appeared (failure sending email). Please anyone help me ASAP.
bool SendMail(string account, string password, string to, string subject, string message)
{
try
{
NetworkCredential loginInfo = new NetworkCredential(elarabyAccount, password);
MailMessage msg = new MailMessage();
msg.From = new MailAddress(account);
msg.To.Add(new MailAddress(to));
msg.Subject = subject;
msg.Body = message;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient("mail.example.com", 8080);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
client.Send(msg);
return true;
}
catch (Exception)
{
return false;
}
}
void BtnSend_Click(object sender, EventArgs e)
{
SendMail("[email protected]", "xxxxx", TxtEmail.Text, "Hi", "Hi");
}