Reputation: 564
Im using laravel and configured mailgun to send mails
I want to use webhooks to track them. so I need to send data with the message so I can track it using the web hook
for example attach a message id to each mail I send
tried to follow the mailgun documnation but no luck
this is my code for sending the mail
$data = array('course_name' => $course_name,'grade' => $grade,'email' => $stud->email,
"v:messageId" => "123");
Mail::send('emails.stud_feedback',$data, function ($message) {
$message->to($this->email)->subject( $this->course);
$message->attach($this->file, ['as' => 'feedback']);
});
according to the documnation the web hook should post me the message id, but Im not getting it.
what am I doing wrong?
Upvotes: 2
Views: 1375
Reputation: 2922
Use This :
Mail::send('emails.test',[]), function ($message) use ($subject, $from, $emails) {
dd($message->getSwiftMessage()->getId());
});
Upvotes: 0
Reputation: 564
solved by setting headers to the mail:
$message->getHeaders()->addTextHeader('X-Mailgun-Variables', "{'messageid:123}'}");
Upvotes: 3