Skip to content

Conversation

asherber
Copy link
Contributor

I see that previous mods have leveraged the MailMessage.Headers in order to get tags and vars working. I took a slightly different approach. I created a new MailgunMessage class which is a descendant of MailMessage and which has fields for most of the things supported by the API – including Tags, Vars, CustomHeaders, DeliveryTime, etc.

FormPartsBuilder now knows how to iterate over these new properties and supply the appropriate form parts to the API call. All of this is backwards-compatible; you can still just use MailMessage if you want, and you can still use the other methods of adding tags and vars.

The only API fields I have not added are inline, because it deals with attachments and is tricky when you don't have file-based attachments, and the htmlonly option for o:tracking-clicks.

This could be extensible in the future – could add MailgunMessageV3_1 or MailgunMessageV4 as new fields are introduced by new API versions. In fact, I thought about making MailgunMessage an abstract base class and calling the current class MailgunMessageV3; let me know if you'd like me to make this change.

@asherber
Copy link
Contributor Author

I went ahead and did the versioned MailgunMessage thing in my feature/apifields-versioned branch, if you want to take a look. If you like that version, I can issue the PR from there instead.

@asherber
Copy link
Contributor Author

I actually now also have inline attachments working. When you have decided whether you prefer the versioned or unversioned MailgunMessage (I think I prefer the versioned), I'll add inline attachments to that branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant