Closed limewareio closed 4 years ago
Sounds right, thanks for the report! Can you toss me some steps to reproduce the issue? Just your commands would be fine. I'll take a look as soon as I can.
Sure! You can try something like the code below to reproduce the issue.
from postmark.core import PMBatchMail, PMMail
SOME_TEMPLATE_ID = 12345678
def send_batch_mail():
recipients = ['john.smith@example.com', 'jane.smith@example.com']
template_model = {'url': 'https://www.example.com'}
batch_mail = PMBatchMail()
for recipient in recipients:
message = PMMail(
to=recipient,
sender='noreply@example.com',
template_id=SOME_TEMPLATE_ID,
template_model=template_model,
)
batch_mail.add_message(message)
batch_mail.send()
I tried sending batch with templates but it doesn't seem to work. If I send it without templates it works as intended.
While browsing through the code I found that 'email/batch' is hard-coded.
I looked at Postmarks API documentation https://postmarkapp.com/developer/api/templates-api#send-batch-with-templates and found that there's a different call for sending batch with templates. I don't know if it has worked before or if they recently made some changes to the endpoints.
Perhaps a solution to the problem could be to pass a flag indicating that you want to send batch with templates and change the 'email/batch' string depending on the value of that flag.