buzzingpixel / corbomite-mailer
Corbomite Mailer
Requires
- php: >=7.2
- buzzingpixel/corbomite-db: ^1.0
- buzzingpixel/corbomite-di: ^1.0
- buzzingpixel/corbomite-queue: ^1.0
- html2text/html2text: ^4.2
- mailgun/mailgun-php: ^2.8
- mandrill/mandrill: ^1.0
- php-http/guzzle6-adapter: ^1.1.1
- sendgrid/sendgrid: ^7.2
- wildbit/postmark-php: ^2.6
Requires (Dev)
- buzzingpixel/corbomite-cli: ^1.0
- codedungeon/phpunit-result-printer: ^0.26.2
- doctrine/coding-standard: ^6.0
- friendsofphp/php-cs-fixer: ^2.14
- phpmd/phpmd: ^2.6
- phpunit/phpunit: ^8.1
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.4
- vlucas/phpdotenv: ^2.5
This package is auto-updated.
Last update: 2024-12-14 07:35:35 UTC
README
Part of BuzzingPixel's Corbomite project.
Provides transaction email capabilities.
Usage
Queue
The Mailer makes use of the Corobomite Queue feature so be sure you have the queue running.
Webmaster From and Email environment variables
For deliverability, emails are ways sent from the the webmaster email. Be sure to set the following environment variables:
WEBMASTER_EMAIL_ADDRESS=info@mysite.com
WEBMASTER_NAME="Some Name"
CORBOMITE_MAILER_ADAPTER_CLASS environment variable
To set what adapter the mailer uses, make sure to set the CORBOMITE_MAILER_ADAPTER_CLASS
environment variable to a fully qualified class name of an adapter. The built-in adapters are:
buzzingpixel\corbomitemailer\adapters\SendGridSendMailAdapter
buzzingpixel\corbomitemailer\adapters\MandrillMailSendMailAdapter
buzzingpixel\corbomitemailer\adapters\MailGunSendMailAdapter
buzzingpixel\corbomitemailer\adapters\PostMarkSendMailAdapter
You can also write your own adapter. It must implement buzzingpixel\corbomitemailer\interfaces\SendMailAdapterInterface
.
Built-in Adapter Environment variables
SendGridSendMailAdapter
To use the SendGridSendMailAdapter
, be sure to set the SENDGRID_API_KEY
environment variable.
MandrillMailSendMailAdapter
To use the MandrillMailSendMailAdapter
, be sure to set the MANDRILL_API_KEY
environment variable.
MailGunSendMailAdapter
To use the MailGunSendMailAdapter
, be sure to set the MAILGUN_API_KEY
and MAILGUN_DOMAIN
environment variables.
PostMarkSendMailAdapter
To use the PostMarkSendMailAdapter
, be sure to set the POSTMARK_SERVER_TOKEN
environment variable.
Sending email
<?php declare(strict_types=1); use corbomite\di\Di; use buzzingpixel\corbomitemailer\interfaces\EmailApiInterface; /** * Requesting the EmailApiInterface will return an instance of \buzzingpixel\corbomitemailer\EmailApi * You can override it with your own implementation by setting to return value of PHP-DI for * the interface to your own implementation */ $emailApi = Di::diContainer()->get(EmailApiInterface::class); $emailModel = $this->emailApi->createEmailModel([ 'fromName' => 'Some Name', // Optional, fromEmail must be set 'fromEmail' => 'Some Email', // Optional 'toName' => 'Some Name', // Optional 'toEmail' => 'someone@domain.com', // Required 'subject' => 'Some Subject', // Required 'messagePlainText' => 'Plaintext Content', // Required if messageHtml not set. Derived from messageHtml if not set 'messageHtml' => '<p>Html Content</p>', // Required if messagePlainText not set ]); // Add the email to the queue and let the queue runner send it (recommended) $emailApi->addEmailToQueue($emailModel); // Send the email right away (avoid if possible) $emailApi->sendEmail($emailModel);
License
Copyright 2019 BuzzingPixel, LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.