-
Notifications
You must be signed in to change notification settings - Fork 28
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
Support for Tags and Metadata? #20
Comments
Just made a pull request #21 |
This would be amazing! :D |
We just fork the repo and change the Line 285: private function processHeaders(&$payload, $message)
{
$headers = [];
foreach ($message->getHeaders()->getAll() as $key => $value) {
$fieldName = $value->getFieldName();
$excludedHeaders = ['Subject', 'Content-Type', 'MIME-Version', 'Date'];
if (!in_array($fieldName, $excludedHeaders)) {
if (
$value instanceof \Swift_Mime_Headers_UnstructuredHeader ||
$value instanceof \Swift_Mime_Headers_OpenDKIMHeader
) {
if ($fieldName != 'X-PM-Tag') {
$metadataField = 'X-PM-Metadata-';
if (substr($fieldName, 0, strlen($metadataField)) == $metadataField) {
$payload["Metadata"][explode($metadataField, $fieldName)[1]] = $value->getValue();
}
array_push($headers, [
"Name" => $fieldName,
"Value" => $value->getValue(),
]);
} else {
$payload["Tag"] = $value->getValue();
}
} else if (
$value instanceof \Swift_Mime_Headers_DateHeader ||
$value instanceof \Swift_Mime_Headers_IdentificationHeader ||
$value instanceof \Swift_Mime_Headers_ParameterizedHeader ||
$value instanceof \Swift_Mime_Headers_PathHeader
) {
array_push($headers, [
"Name" => $fieldName,
"Value" => $value->getFieldBody(),
]);
if ($value->getFieldName() == 'Message-ID') {
array_push($headers, [
"Name" => 'X-PM-KeepID',
"Value" => 'true',
]);
}
}
}
}
$payload['Headers'] = $headers;
} This can handle multiple Metadata since the opened pull request only support one (the last entered) |
Hi there. Thanks for the PR. We are actually in the process of correcting this in the API so that no updates will be required as we continue to add |
@atheken Will you inform postmark users with an email at least or something before you pushed you |
@izio38 - We announce changes in the API, and this will be no different. However, the change is additive, and really won't break anything, even your patch, here's why: This transport translates SMTP requests into API calls. An oversight in our API endpoints was that there are cases like this where X-PM-* headers drive behavior/set properties of sends in SMTP, but not in normal API requests (such as Tags, Metadata, etc.). We are updating our API so that Since we are making this the responsibility of the API, all future In the case of this patch, if you map the metadata headers, this will set the API payload property, and the We are obviously assuming the user intent was for Let me know if this alleviates your concerns, and if not, feel free to contact our support team with additional questions. |
@atheken Do you know anything about when to expect it to be implemented in your api? |
@AndreasHerss - we deployed this late last week, you should be all set. |
Thanks again for the PR @izio38 - we do appreciate these enhancements, but we're trying to defer most of this work to the API so that customers don't need to update their clients as frequently/when we add new functionality. As I mentioned, this is now built in to the API, so no special handling is required by this transport. |
@atheken Sweet! just hadn't tried it since this issue was still open :) thank you! |
Hello there!
I'm using Laravel and Postmark using this adapter. I'm trying to send a message and add metadata/tags to it. Reading through the code & docs, I figured my best bet would be to add X-PM headers as per the SMTP documentation. I tried doing that:
The headers do get added to the message (I can see them when clicking the "raw source" tab in the UI) but Postmark doesn't seem to care for such headers when using the API.
Maybe it's possible to handle these special headers in the adapter? I see that there is some kind of precedent here.
Thank you!
Guilherme
The text was updated successfully, but these errors were encountered: