Comments (10)
Just made a pull request #21
from swiftmailer-postmark.
@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 X-PM-*
headers will be used when present, but their corresponding request payload properties are absent in API requests (i.e. respect the explicit API payload properties when present, but set them if they are not present, but corresponding X-PM-*
headers are included in the request).
Since we are making this the responsibility of the API, all future X-PM-*
headers that we support will automatically be supported by any library that translates SMTP messages to API requests, even if that library does not explicitly handle those new headers.
In the case of this patch, if you map the metadata headers, this will set the API payload property, and the X-PM-Metadata-*
headers are not needed, but as I said, this will be handled automatically by the API in either case.
We are obviously assuming the user intent was for X-PM-Metadata-*
headers to be mapped as metadata in Postmark messages, but we believe this is a reasonable assumption, given the historic use of X-PM-*
headers in Postmark.
Let me know if this alleviates your concerns, and if not, feel free to contact our support team with additional questions.
from swiftmailer-postmark.
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.
from swiftmailer-postmark.
This would be amazing! :D
from swiftmailer-postmark.
We just fork the repo and change the Transport.php
file.
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)
from swiftmailer-postmark.
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 X-PM-*
header support for new Postmark features. You should expect this to automatically start working in the next week or two.
from swiftmailer-postmark.
@atheken Will you inform postmark users with an email at least or something before you pushed you fix
into production?
from swiftmailer-postmark.
@atheken Do you know anything about when to expect it to be implemented in your api?
i really need this feature 😅
from swiftmailer-postmark.
@AndreasHerss - we deployed this late last week, you should be all set.
from swiftmailer-postmark.
@atheken Sweet! just hadn't tried it since this issue was still open :) thank you!
from swiftmailer-postmark.
Related Issues (19)
- dependency inversion HOT 3
- Swift_Mime_Message is removed since 6.0 HOT 3
- Swift Mailer 6 compatibility HOT 7
- Error Handling
- token rather than serverToken referenced HOT 1
- Receiving type error for Transport::convertEmailsArray HOT 2
- Retrieve MessageID from response HOT 3
- Supporting Yii sendMultiple()
- Support for Broadcasting Streams HOT 1
- Support Guzzle 7 HOT 3
- Does not work with Laravel 8 (Guzzle 7) HOT 2
- Use multiple postmark drivers with stream ID in Laravel application HOT 7
- Support for Batch Email ? HOT 2
- License
- Package swiftmailer/swiftmailer is abandoned HOT 1
- Wrong return type for send function HOT 3
- text/plain body is not sent using setBody() HOT 2
- Remove suggestion of wildbit/laravel-postmark-provider (~1.0) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftmailer-postmark.