mailgun / mailgun-go

Go library for sending mail with the Mailgun API.
BSD 3-Clause "New" or "Revised" License
700 stars 143 forks source link

feat: added Send Time Optimization (STO) param #304

Closed cjyang0117 closed 1 year ago

cjyang0117 commented 1 year ago

Purpose: Add Send Time Optimization (STO) functionality. STO is a Mailgun feature that utilizes machine learning to determine the optimal time to deliver a message to a recipient. The goal is to deliver the message right before the recipient typically checks their email, increasing the chances of engagement and improving overall engagement rates, leading to higher conversions and increased ROI.

Implementation Details: Introduce a new method, SetSTOPeriod, to the Message class, which allows setting the o:deliverytime-optimize-period parameter (https://documentation.mailgun.com/en/latest/api-sending.html#sending). The parameter follows the specification: "Toggles Send Time Optimization (STO) on a per-message basis. The string should be set to the number of hours in [0-9]+h format, with a minimum of 24h and a maximum of 72h." The implemented code performs checks to ensure adherence to this specification.