Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MailCare Request #95

Closed
wants to merge 5 commits into from
Closed

Update MailCare Request #95

wants to merge 5 commits into from

Conversation

mailcare
Copy link

The MailCare driver doesn't work.

This PR will fix the issue.

@joelharkes
Copy link

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

@eXorus
Copy link
Contributor

eXorus commented Sep 3, 2022

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

@joalea
Copy link

joalea commented Dec 26, 2022

Please accept this PR! 👍

siebsie23 added a commit to siebsie23/laravel-mailbox that referenced this pull request Feb 17, 2023
@joelharkes
Copy link

@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?

@siebsie23
Copy link

@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?

}

public function email()
{
return InboundEmail::fromMessage($this->get('email'));
return InboundEmail::fromMessage(file_get_contents('php://input'));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably this would do as well:

Suggested change
return InboundEmail::fromMessage(file_get_contents('php://input'));
return InboundEmail::fromMessage($this->post());

to get all input

@mailcare mailcare closed this by deleting the head repository Mar 2, 2023
@joelharkes
Copy link

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
Copy link

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

image

@eXorus
Copy link
Contributor

eXorus commented Mar 5, 2023

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

A new PR has been created: #114 and it has been fully tested.

@joelharkes
Copy link

@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

@eXorus
Copy link
Contributor

eXorus commented Mar 8, 2023

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.

@joelharkes
Copy link

joelharkes commented Mar 10, 2023

@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

@eXorus
Copy link
Contributor

eXorus commented Mar 11, 2023

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.

@joelharkes
Copy link

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
Copy link

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

image

@joelharkes
Copy link

@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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants