HMailServer发送邮件并请求回执
public static void SendHMail(MailAddress mailTo, string mailSubject, string mailBody, MailAddress cc = null) { string MAIL_FROM = "test@test.com"; string body = System.DateTime.Now.ToString() + "<br/>"; body += mailBody + "<br/><br/><div style=\"font-size: 25px; font-weight: bold;\">Regards<br/>" + MAIL_FROM + "</div>"; MailMessage mail = new MailMessage { From = new MailAddress(MAIL_FROM), Subject = mailSubject, Body = body, BodyEncoding = Encoding.UTF8, IsBodyHtml = true }; mail.Headers.Add("Disposition-Notification-To", "<receipt@xxx.com>");//接收回执信息的邮箱地址 mail.To.Add(mailTo); if (cc != null) { mail.CC.Add(cc); } SmtpClient smtpClient = new SmtpClient(); smtpClient.Host = "100.168.168.168"; smtpClient.Port = Convert.ToInt32(25); smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.Credentials = new NetworkCredential("userName", "passWord"); smtpClient.Send(mail); }
需要引用System.Net.Mail.其中
mail.Headers.Add("Disposition-Notification-To", "<receipt@xxx.com>");
实现了请求回执功能,第二个参数是接收回执的邮箱。
HMail邮件服务器搭建没什么好说的,执行安装程序,一直下一步就可以完成安装。
安装完成以后,可以通过OutLook连接HMail.配置如下: