laravel-mailbox icon indicating copy to clipboard operation
laravel-mailbox copied to clipboard

Accessing the ID of an inbound email

Open JapSeyz opened this issue 5 years ago • 2 comments

Hi,

I'd like to store some incoming mails after parsing them, but I'd like to have a reference to them in the data I create from the parsed mail. IE the model ID the InboundEmail model that I get in my Mailbox (not the mail ID).

The InboundEmail is not yet persisted once it reaches my mailbox, is there any issues with calling $inboundEmail->save(); within the mailbox? This would allow me to get the ID and store the reference to the raw mail.

Cheers,

JapSeyz avatar Nov 16 '19 22:11 JapSeyz

Hello,

Your question is a little old, but since it has no answer and I'm facing a similar situation - I need the Email's id in my mailbox route handler. There is no issue in calling $inboundEmail->save(); there, apart from the fact that it duplicates the call in Routing/Router::storeEmail() (which is called after the route handler - there).

Is there a reason, @mpociot, why storeEmail() is not called before the route handler?

Another solution would be the message_id attribute, but that is only assigned upon the model's creating event... That is, while saving, which boils down to the same problem.

pecuchet avatar Dec 08 '20 08:12 pecuchet

@pecuchet & @JapSeyz could you not access the the id's in the created eloquent event?

joelharkes avatar Aug 11 '22 13:08 joelharkes