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

Update MailCare Request

Open mailcare opened this issue 3 years ago • 2 comments

The MailCare driver doesn't work.

This PR will fix the issue.

mailcare avatar Jan 20 '22 11:01 mailcare

@mailcare is this still an issue? i can fix it in my fork: https://github.com/joelharkes/laravel-mailbox

joelharkes avatar Aug 11 '22 13:08 joelharkes

Yes still an issue, but the PR are not merged. I'm not sure Laravel mailbox is still used.

eXorus avatar Sep 03 '22 11:09 eXorus

Please accept this PR! 👍

joalea avatar Dec 26 '22 19:12 joalea

@joalea and @siebsie23 Im trying to solve it but i dont understand how this code would solve it.

When i read the documentation: https://mailcare.docs.apiary.io/#reference/0/automations-resource/automation-webhook

it suggests getting the email from data.sender.email not from php://input Do i have the right documentation?

joelharkes avatar Feb 21 '23 19:02 joelharkes

@joelharkes To be honest I'm not sure. I just blindly merged it into my fork. But in theory the php://input should just get the full raw body of the email right?

siebsie23 avatar Feb 21 '23 19:02 siebsie23

As far as i understand, this would store the complete JSON in the message field in the database, but not the actual EML file/ email file. Im looking at how to get this but i do not see, even the get email api call seems to have no contents? you can only download attachements?

see: https://mailcare.docs.apiary.io/#reference/0/email-resource/get-an-email

joelharkes avatar Mar 05 '23 15:03 joelharkes

Instead it seems like you have to checkbox the "Post the raw, full MIME message": https://github.com/mailcare/mailcare

image

joelharkes avatar Mar 05 '23 15:03 joelharkes

Yes it works only if you check the checkbox "Post the raw, full MIME message".

A new PR has been created: https://github.com/beyondcode/laravel-mailbox/pull/114 and it has been fully tested.

eXorus avatar Mar 05 '23 15:03 eXorus

@eXorus actually php://input would have been required to get the full http headers and body. But that for example does not work with Laravel Octane.

Im not sure there is a proper solution for this. Only maybe this would work: https://stackoverflow.com/a/23447426/1275832

joelharkes avatar Mar 05 '23 16:03 joelharkes

But you don't need to have the http headers, you only need the email body and Laravel mailbox will decode the email for you. It's exactly how the other drivers works: postmark with the rawemail attribute, sendgrid with the email attribute.

eXorus avatar Mar 08 '23 14:03 eXorus

@eXorus the HTTP headers are equal to the Email headers, it contains who send the email and who received it ETC.

So they are picked up as HTTP headers and you will only get the Email HTML body and miss all the email context information

joelharkes avatar Mar 10 '23 11:03 joelharkes

Sorry I don't understand, the other drivers works the same they send more information in a Json properties like subject or to but they are not used by laravel mailbox because Laravel mailbox use only the raw email (with email headers and bodies) to decode the subject...

So same for MailCare but I don't send the decoded subject, because laravel mailbox don't need it.

From a user point of view you will have all the emails headers and all the emails bodies.

eXorus avatar Mar 11 '23 18:03 eXorus

No, the email headers are filtered out by PHP (as they are identical as HTTP header structure they are seen as HTTP headers).

I did some testing locally. When I have more time I'll make a proper PR to make it work in any circumstance although maybe not the ideal solution.

joelharkes avatar Mar 11 '23 18:03 joelharkes

Found proper solution as i could get: doing $request->__toString() It does add extra HTTP requests, maybe good fallback for php://input

image

joelharkes avatar Mar 24 '23 16:03 joelharkes

@eXorus i was wrong it, does seem to POST the whole email message in the HTTP Body (it doesn not skip the HTTP request)

https://github.com/mailcare/mailcare/blob/7f9973e1dfaed42811fd64b9a7c81fc0e6e47230/app/Listeners/AutomationListener.php#L83

joelharkes avatar Mar 24 '23 17:03 joelharkes

@eXorus my Fork supports it now with proper testing also: https://packagist.org/packages/joelharkes/laravel-mailbox

joelharkes avatar Mar 24 '23 17:03 joelharkes