beyondcode / laravel-mailbox

Catch incoming emails in your Laravel application
https://beyondco.de/docs/laravel-mailbox/getting-started/introduction
MIT License
1.02k stars 127 forks source link

Accessing the ID of an inbound email #48

Open JapSeyz opened 4 years ago

JapSeyz commented 4 years ago

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,

pecuchet commented 3 years ago

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.

joelharkes commented 2 years ago

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