postal
postal copied to clipboard
Post processing view output
would be nice if there was a hook that enabled us to post-process the generated view output - then could use premailer.net to automatically inline all the css
https://github.com/milkshakesoftware/PreMailer.Net
currently having to generate the email to Net.MailMessage then process it and send it myself
There's not a simple hook for this, however, it's possible.
Implement the Postal.IEmailParser interface and delegate the implementation to an instance of Postal.EmailParser. Transform the resulting MailMessage as required before returning it.
Then create your own subclass of EmailService, where you use the custom email parser. https://github.com/andrewdavey/postal/blob/master/src/Postal/EmailService.cs
Finally, put this in Application_Start if you want the Email.Send() to use the new implementation:
Postal.Email.CreateEmailService = () => new CustomEmailService()
If you have thoughts on how to provide a built-in hook, then I'd be happy to take a look at a pull request.
Hi Andrew
Thanks for this, I'll take a look later
I'll see what I can do about investigating where a hook point could sensibly go also
Much appreciated
Scott On 24 Oct 2014 14:38, "Andrew Davey" [email protected] wrote:
There's not a simple hook for this, however, it's possible.
Implement the Postal.IEmailParser interface and delegate the implementation to an instance of Postal.EmailParser. Transform the resulting MailMessage as required before returning it.
Then create your own subclass of EmailService, where you use the custom email parser. https://github.com/andrewdavey/postal/blob/master/src/Postal/EmailService.cs
Finally, put this in Application_Start if you want the Email.Send() to use the new implementation: Postal.Email.CreateEmailService = () => new CustomEmailService()
If you have thoughts on how to provide a built-in hook, then I'd be happy to take a look at a pull request.
— Reply to this email directly or view it on GitHub https://github.com/andrewdavey/postal/issues/94#issuecomment-60387559.
I don't know if this helps but here is a gist that shows how we use premailer with postal https://gist.github.com/paulduran/91dd14c0eecc6b1ff22f
cheers, Paul
@paulduran @plmeister Your gist is great, but it has a bug with images, which are not included. I've added a comment with a fix to that gist.