Stampie / Stampie

Library for using online Email providers
https://stampie.github.io
MIT License
294 stars 30 forks source link

Support sending messages using merge tags/substitutions #53

Closed stof closed 2 years ago

stof commented 9 years ago

Sendgrid and Mandrill are supporting merge tags. This could allow to offload our servers by avoiding to generate a different email for each recipient when only small variations are needed

henrikbjorn commented 9 years ago

How does that work, you save the copy in their systems and just uses these merge tags?

stof commented 9 years ago

When sending the API call, the body of the message contains stuff like *|USERNAME|* and the request contain an additional parameter giving values for variables (username in this case) for each recipient. Then, the Mandrill server will generate a separate message per recipient and replace merge tags with their values.

This is similar on Sendgrid (which call them substitutions) except that the don't enforce the *|...|* delimiters for them and just replace what you pass a variable.

Mailgun and Postmark don't seem to support it AFAICT. There is 2 solutions here:

The remaining question is how much we want to abstract the differences between Sendgrid and Mandrill regarding the implementation of the feature.

stof commented 2 years ago

Supporting that without abstracting the differences does not make sense (if the code is coupled to a single mailer implementation anyway, using the SDK of that provider makes more sense). And abstracting differences would be very hard.