api-documentation icon indicating copy to clipboard operation
api-documentation copied to clipboard

custom headers with smpt relay

Open thber190356 opened this issue 5 years ago • 3 comments

When I'm sending custom headers using SMTP relay, my mayljet transactional template is assigned correctly with the X-MJ-TemplateID but X-MJ-Vars variables are not included in the content of the template. Any idea what I'm doing wrong?

Code in PHPMailer: $mail->addCustomHeader('X-MJ-TemplateID','xxxxx'); $mail->addCustomHeader('X-MJ-TemplateLanguage','true'); $mail->addCustomHeader('X-MJ-Vars','{"name":"xxx", "city:xxx"}');

thber190356 avatar Jan 06 '20 23:01 thber190356

Hi @thber190356, use $mail->addCustomHeader('X-MJ-TemplateLanguage','1'); instead

AntoineGst avatar Oct 06 '21 09:10 AntoineGst

Hello @thber190356 @AntoineGuestin I've the same issue implementing it via Symfony: no way to get the Vars values in sent mail when other headers are OK :( @thber190356 did you finally found a solution ? thanks a lot

thacac avatar May 08 '22 20:05 thacac

I found a solution for this issue! You MUST pass the Json object as string. I used 'X-MJ-Vars': JSON.stringify(variables)} and it worked

NashIlli avatar May 26 '22 21:05 NashIlli