I want to send batch emails with attachment. I can send the batch emails by attaching the same file to all the emails. But I need to attach different files to different emails by adding file path in recipient variables. I can't see anything related in the official documentation of mailgun.
Here is my code :
# Instantiate the client.
$mgClient = new Mailgun('key-****');
$domain = "foo.bar.com";
# Make the call to the client.
$result = $mgClient->sendMessage($domain, array(
'from' => 'gido@foo.baar.com',
'to' => array('user1@gmail.com', 'user2@gmail.com'),
'subject' => 'Hi %recipient.first%',
'text' => 'Hey there, Just Testing',
'recipient-variables' => '{"user1@gmail.com": {"first":"User1", "id":1, "file" : "/path/to/file1"},
"user2@gmail.com": {"first":"User2", "id": 2, "file" : "/path/to/file2"}}'
), array(
'attachment' => array('%recipient.file%')
));
The above code does not work. the attachment array is not able to use recipient variable. Replacing %recipient.image%
with /path/to/file
works fine.