GithubHelp home page GithubHelp logo

Comments (10)

drakakisgeo avatar drakakisgeo commented on June 16, 2024 3

Just made a pull request #21

from swiftmailer-postmark.

atheken avatar atheken commented on June 16, 2024 2

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

atheken avatar atheken commented on June 16, 2024 1

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.

AndreasHerss avatar AndreasHerss commented on June 16, 2024

This would be amazing! :D

from swiftmailer-postmark.

IzioDev avatar IzioDev commented on June 16, 2024

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.

atheken avatar atheken commented on June 16, 2024

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.

IzioDev avatar IzioDev commented on June 16, 2024

@atheken Will you inform postmark users with an email at least or something before you pushed you fix into production?

from swiftmailer-postmark.

AndreasHerss avatar AndreasHerss commented on June 16, 2024

@atheken Do you know anything about when to expect it to be implemented in your api?
i really need this feature 😅

from swiftmailer-postmark.

atheken avatar atheken commented on June 16, 2024

@AndreasHerss - we deployed this late last week, you should be all set.

from swiftmailer-postmark.

AndreasHerss avatar AndreasHerss commented on June 16, 2024

@atheken Sweet! just hadn't tried it since this issue was still open :) thank you!

from swiftmailer-postmark.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.