I\'ve got a simple method to send emails from the website:
... // local vars
using (var mail = new MailMessage(from, sendTo))
{
using (var smtp = new Smt
I made a tool for sending email`s with this configurations:
MailMessage mail = new MailMessage("senderaddress", "recipientaddress");
SmtpClient client = new SmtpClient()
{
Host = "smtpserver",
Port = 587,//standard port for the most of the server`s
DeliveryMethod = SmtpDeliveryMethod.Network,
EnableSsl = true,
UseDefaultCredentials = false//I got the address and the password so I don`t need the default-credentials
};
NetworkCredential na = new NetworkCredential("yoursender", "senderpassword");//I let the user input his email-address and password to get auntenthificated
client.Credentials = na;
mail.Subject = "subject";
mail.Body = "body";
mail.IsBodyHtml = true;//I use to send html formated text
try
{
client.Send(mail);
}
catch (Exception)//for debugging purposes I used the default exception
{
MessageBox.Show("Sending failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
It worked fine for me, when I wanted to send from one domain to the same host, so I hope it works also fine for you!