How to configure SMTP settings in web.config

By setting the values <mailSettings> section of the in the web.config you can just new up an SmtpClient and the client will use those settings. Web.Config file: <configuration> <> <mailSettings> <smtp from=””> <network host=”” port=”587″ userName=”” password=”yourpassword” enableSsl=”true”/> </smtp> </mailSettings> </> </configuration> C#: SmtpClient smtpClient = new SmtpClient(); smtpClient.Send(msgMail); However, if authentication is needed, … Read more

Precedence: header in email

There is a RFC 3834 dedicated for automated email responses. In short, it recommends: Send auto-responses only to address contained in the Return-Path header of an incoming message, if it is valid email address. Particularly “<>” (null address) in the Return-Path of the message means that auto-responses must not be sent for this message. When … Read more

Nodemailer/Gmail – What exactly is a refresh token and how do I get one?

Notes by this answer original’s author: So, I finally managed to figure it out. I’m surprised I couldn’t find more ressources about that so for those who need to use Gmail with Nodemailer I found the answer here: Try creating a new User if you already had one and things ain’t working fine. It … Read more

Email model validation with DataAnnotations and DataType

DataType attribute is used for formatting purposes, not for validation. I suggest you use ASP.NET MVC 3 Futures for email validation. Sample code: [Required] [DataType(DataType.EmailAddress)] [EmailAddress] public string Email { get; set; } If you happen to be using .NET Framework 4.5, there’s now a built in EmailAddressAttribute that lives in System.ComponentModel.DataAnnotations.EmailAddressAttribute.