This will show you how to utilize official SMTP (Simple Mail Transfer Protocol) servers to send emails in your C# applications. All you need is a Hotmail, Yahoo, or Gmail email account.
First, declare the usage of the System.Text and System.Net.Mail namespaces in your respective class.
Then, create an object of the SmtpClient type.
var client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("Sending Email Account Address", "Sending Email Account Password");
Now, set the host and the port of your SmtpClient.
client.EnableSsl = false;
client.Host = ip;
client.Port = port;
Use this as a reference for such information.
HOTMAIL: Maximum outgoing = 300 per day
Port = 25 OR 465
Host = smtp.live.com (it seems to be down)
Ssl = true
GMAIL: Maximum outgoing = 500 per day
Port = 465
Host = smtp.gmail.com
Ssl = false;
YAHOO: Maximum outgoing = 500 per day
Port = 465
Host = smtp.mail.yahoo.com
Ssl = false
Now that we have our client all finished, we can begin to compose our email.
var message = new MailMessage();
message.From = new MailAddress("sending email address");
message.To.Add("sending email");
message.Body = "The email itself";
message.Subject = "Subject of the email";
message.BodyEncoding = UTF8Encoding.UTF8;
If you want to receive an email when the email fails, we can do that too.
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
All that's left to do is send the message.
client.Send(message);