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);
        }
C#

須要引用System.Net.Mail.其中服務器

mail.Headers.Add("Disposition-Notification-To", "<receipt@xxx.com>");

實現了請求回執功能,第二個參數是接收回執的郵箱。ide

HMail郵件服務器搭建沒什麼好說的,執行安裝程序,一直下一步就能夠完成安裝。spa

安裝完成之後,能夠經過OutLook鏈接HMail.配置以下:code

相關文章
相關標籤/搜索