How do websites send email when new replies are posted to a question
4 answers
The recipients don't matter as long as you have access to the SMTP server. The code looks something like this, you can get a lot more just by emailing Google.
using System.Net.Mail;
...
var msg = new MailMessage();
msg.From = new MailAddress("me@my.com");
msg.To.Add("you@yours.com");
msg.Subject = "Blah";
msg.Body = "Stuff";
var smtp = new SmtpClient("smtpServerNameOrAddress");
smtp.Send(msg);
+2
a source to share
It depends on the type of server used,
for example if you are using Apache and PHP you can use SendMail to send emails
and if you are using ASP.NET you can send it using any free SMTP server like GMail
Here's some sample code:
SmtpClient smtpobj = new SmtpClient();
MailMessage mail = new MailMessage();
mail.From = new MailAddress("username@gmail.com");
mail.To.Add("abc@def.com");
mail.Subject = "Subject";
mail.Body ="<p> Content Here </p>;
smtpobj.Host = "smtp.gmail.com";
smtpobj.Pot = 587;
smtpobj.EnableSsl = true;
smtpobj.Credentials = new NetworkCredential("user", "pass");
mail.Priority = MailPriority.High;
mail.IsBodyHtml = true;
smtpobj.Send(mail);
+1
a source to share