swiftmailer-postmark icon indicating copy to clipboard operation
swiftmailer-postmark copied to clipboard

Retrieve MessageID from response

Open warksit opened this issue 5 years ago • 3 comments

Is there a way to do this currently? Other packages such as https://github.com/craigpaul/laravel-postmark add this as a header like so when the message is sent:

  $message->getHeaders()->addTextHeader(
            'X-PM-Message-Id',
            $this->getMessageId($response)
        );

I'd like to use this package as it is the Laravel recommendation but require this functionality. Would you be interested in a Pull Request?

warksit avatar Nov 27 '19 04:11 warksit

Any news on this one? I would like to retrieve the Postmark ID after sending the mail, can't figure out how!

dejury avatar Jun 29 '21 07:06 dejury

The way I acheieved this is listen for the Illuminate\Mail\Events\MessageSent Event and in the listener you can retrieve the ID

public function handle(MessageSent $email)
{
    $email->message->getHeaders()->get('X-PM-Message-Id')->getValue()
}

warksit avatar Jun 29 '21 09:06 warksit

The way I acheieved this is listen for the Illuminate\Mail\Events\MessageSent Event and in the listener you can retrieve the ID

public function handle(MessageSent $email)
{
    $email->message->getHeaders()->get('X-PM-Message-Id')->getValue()
}

I doubt this works in the current version. Created a PR to support this.

dejury avatar Jun 29 '21 09:06 dejury