简体   繁体   中英

How to set X-Mailgun-Campaign-Id header in Mailgun php API?

How to set up header "X-Mailgun-Campaign-Id" in Mailgun php API?

I'm using the following code, but I don't know how to pass campaign ID in the header:

Mail::send('email.message', $data, function ($message) use ($data) {
    $message->to($data['to_email'], $data['to_name'])
        ->subject($data['subject'])
        ->from($data['from_email'], $data['from_name'])
        ->header('X-Mailgun-Campaign-Id', 'test campaign');
});

Solution has been found:

Mail::send('emails.test3', array(), function ($message) {
    $message->to('barsnur@gmail.com')
        ->subject('Смоторим ответа об открытии')
        ->from('noreply@mg.offer.bz');

    $headers = $message->getHeaders();
    $headers->addTextHeader('X-Mailgun-Variables', '{"id_message": "666"}');
    $headers->addTextHeader('X-Mailgun-Tag', 'test-tag');
    $headers->addTextHeader('X-Mailgun-Campaign-Id', 'sDas7d');
});

List of available headers are for the link https://documentation.mailgun.com/user_manual.html#sending-via-smtp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM