All Projects → wildbit → swiftmailer-postmark

wildbit / swiftmailer-postmark

Licence: other
The Official Swiftmailer Transport for Postmark.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to swiftmailer-postmark

postmark-wordpress
The Official Postmark Wordpress Plugin
Stars: ✭ 17 (-67.31%)
Mutual labels:  mail, postmark, postmark-integrations
laravel-postmark-provider
A Postmark adapter for Laravel 5+
Stars: ✭ 29 (-44.23%)
Mutual labels:  postmark, postmark-integrations
go-mail
📨 Simple email interface across multiple service providers (ses, postmark, mandrill, smtp)
Stars: ✭ 39 (-25%)
Mutual labels:  mail, postmark
go-mail
📧 A cross platform mail driver for GoLang. Featuring Mailgun, Postal, Postmark, SendGrid, SparkPost & SMTP.
Stars: ✭ 169 (+225%)
Mutual labels:  mail, postmark
SlmMail
Send mail from Laminas or Mezzio using external mail services.
Stars: ✭ 107 (+105.77%)
Mutual labels:  mail, postmark
Ptorx
📩🛡 Email privacy. Anonymously send and receive with alias forwarding.
Stars: ✭ 187 (+259.62%)
Mutual labels:  mail
Edu Account Creator
Stars: ✭ 225 (+332.69%)
Mutual labels:  mail
Premailer
Preflight for HTML email
Stars: ✭ 2,173 (+4078.85%)
Mutual labels:  mail
Quotefixformac
QuoteFix for Apple Mail —
Stars: ✭ 181 (+248.08%)
Mutual labels:  mail
rb-sisimai
Mail Analyzing Interface for email bounce: A Ruby library to parse RFC5322 bounce mails and generating structured data as JSON from parsed results. Ruby version of Sisimai: an error mail analyzer.
Stars: ✭ 78 (+50%)
Mutual labels:  mail
Meli
🐝 experimental terminal mail client, mirror of https://git.meli.delivery/meli/meli.git https://crates.io/crates/meli
Stars: ✭ 242 (+365.38%)
Mutual labels:  mail
Spstorkcontroller
Now playing controller from Apple Music, Mail & Podcasts Apple's apps.
Stars: ✭ 2,494 (+4696.15%)
Mutual labels:  mail
Go Message
✉️ A streaming Go library for the Internet Message Format and mail messages
Stars: ✭ 193 (+271.15%)
Mutual labels:  mail
Mailu
Insular email distribution - mail server as Docker images
Stars: ✭ 3,151 (+5959.62%)
Mutual labels:  mail
Spamassassin
Read-only mirror of Apache SpamAssassin. Submit patches to https://bz.apache.org/SpamAssassin/. Do not send pull requests
Stars: ✭ 184 (+253.85%)
Mutual labels:  mail
Tmail
Golang SMTP server
Stars: ✭ 251 (+382.69%)
Mutual labels:  mail
Neomutt
✉️ Teaching an Old Dog New Tricks -- IRC: #neomutt on irc.libera.chat
Stars: ✭ 2,343 (+4405.77%)
Mutual labels:  mail
Wepush
专注批量推送的小而美的工具,目前支持:模板消息-公众号、模板消息-小程序、微信客服消息、微信企业号/企业微信消息、阿里云短信、阿里大于模板短信 、腾讯云短信、云片网短信、E-Mail、HTTP请求、钉钉、华为云短信、百度云短信、又拍云短信、七牛云短信
Stars: ✭ 2,597 (+4894.23%)
Mutual labels:  mail
Enmime
MIME mail encoding and decoding package for Go
Stars: ✭ 246 (+373.08%)
Mutual labels:  mail
Ad Hoc Email Server
An ad-hoc disposable temporary mail server. Create and use ad hoc disposable mailboxes for testing or any other purpose.
Stars: ✭ 201 (+286.54%)
Mutual labels:  mail

swiftmailer-postmark

Build Status

An official Swiftmailer Transport for Postmark.

Send mail through Postmark from your favorite PHP frameworks!

Usage

1. Include this package in your project:

composer require wildbit/swiftmailer-postmark

2. Use the transport to send a message:

<?php
//import the transport from the standard composer directory:
require_once('./vendor/autoload.php');

$transport = new \Postmark\Transport('<SERVER_TOKEN>');
$mailer = new Swift_Mailer($transport);

//Instantiate the message you want to send.
$message = (new Swift_Message('Hello from Postmark!'))
  ->setFrom(['[email protected]' => 'John Doe'])
  ->setTo(['[email protected]'])
  ->setBody('<b>A really important message from our sponsors.</b>', 'text/html')
  ->addPart('Another important message from our sponsors.','text/plain');

//Add some attachment data:
$attachmentData = 'Some attachment data.';
$attachment = new Swift_Attachment($attachmentData, 'my-file.txt', 'application/octet-stream');

$message->attach($attachment);

//Send the message!
$mailer->send($message);
?>

3. Throw exceptions on Postmark api errors:

$transport = new \Postmark\Transport('<SERVER_TOKEN>');
$transport->registerPlugin(new \Postmark\ThrowExceptionOnFailurePlugin());

$message = new Swift_Message('Hello from Postmark!');
$mailer->send($message); // Exception is throw when response !== 200

4. Use default headers:

You can set default headers at Transport-level, to be set on every message, unless overwritten.

$defaultHeaders = ['X-PM-Tag' => 'my-tag'];

$transport = new \Postmark\Transport('<SERVER_TOKEN>', $defaultHeaders);

$message = new Swift_Message('Hello from Postmark!');

// Overwriting default headers
$message->getHeaders()->addTextHeader('X-PM-Tag', 'custom-tag');

5. Setting the Message Stream:

By default, the "outbound" transactional stream will be used when sending messages.

// Change the default stream for every message via Default Headers
$transport = new \Postmark\Transport('<SERVER_TOKEN>', ['X-PM-Message-Stream' => 'your-custom-stream']);

$message = new Swift_Message('Hello from Postmark!');

// Overwrite the default stream for a specific message by setting the header
$message->getHeaders()->addTextHeader('X-PM-Message-Stream', 'another-stream');

6. Getting the Postmark Message ID after sending

After sending the mail to Postmark, it is possible to get the Postmark ID.

$transport = new \Postmark\Transport('<SERVER_TOKEN>', $defaultHeaders);
$mailer = new Swift_Mailer($transport);

$message = new Swift_Message('Hello from Postmark!');

$mailer->send($message);

$postmarkID = $message->getHeaders()->get('X-PM-Message-Id')->getValue();

Releasing a new version

Swiftmailer Transport uses packagist. To publish a new version, simply create a new release on GitHub tagged with the version number.

Notes:

  • The Transport uses the Postmark API internally to send mail, via the /email endpoint. Other sending features such as Batch sending or sending via Templates are currently not supported by this library.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].