smsohan / MvcMailer

A Mailer for ASP.Net MVC that forms the Email Body using MVC Views (Razor etc.) following Ruby on Rails ActionMailer style
MIT License
585 stars 176 forks source link

Confirm read #119

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hi, is it possible to send message with "confirm read" flag?

jamesbascle commented 10 years ago

Hi @rafalk2,

It is possible, and quite easy too!

In a mailer's method, simply do something like the following to add any needed headers, including to request a read confirmation:

    public class TestMailer : MailerBase, ITestMailer   
    {      
        public virtual MvcMailMessage Test()
        {
            return Populate(x =>
            {
                x.Subject = "Test";
                x.ViewName = "Test";
                x.MasterName = "_Layout";
                x.Headers.Add("Disposition-Notification-To", "sampleSender@github.com");
                x.Headers.Add("Return-Receipt-To", "sampleSender@github.com");
                x.Headers.Add("X-Confirm-Reading-To", "sampleSender@github.com");
                x.To.Add("testSend@github.com");
            });
        }
    }

I've shown 3 different common read receipt request headers, there may be more, and the other person's email client, server, or provider may not support them all, so don't rely on them too much unless you know the recipient's email client and provider support them!

ghost commented 10 years ago

That's what I need. Thank you!