shippinno/email

There is no license information available for the latest version (v1.0.4) of this package.

v1.0.4 2022-01-21 07:10 UTC

This package is not auto-updated.

Last update: 2024-12-20 22:18:39 UTC


README

Scrutinizer Code Quality Code Coverage Build Status

Installation

$ composer require shippinno/email

Usage

Use a SendEmail to send an Email. It reattempts to send if $maxReattempts attribute is set.

use Shippinno\Email\SwiftMailer\SwiftMailerSendEmail;
use Tanigami\ValueObjects\Web\Email;
use Swift_Mailer;

$sendEmail = new SwiftMailerSendEmail(new Swift_Mailer(...));
$sendEmail->execute(
    new Email(...),
    3 // max reattempts
);

Dealing with non RFC email address

Swift Mailer

Swift Mailer rejects Non RFC compliant email addresses by default.

You can set a custom email validator and Mime grammer (for Swift Mailer 5.x compatibility) allowing non RFC email address (e.g. email.@example.com) by calling allow_non_rfc_email_address(); function.

use function Shippinno\Email\SwiftMailer\register_swift_non_rfc_email_validator;

allow_non_rfc_email_address();
(new Swift_Message)->setTo('email.@example.com'); // => OK

EmailAddress object

Tanigami\ValueObjects\Web\EmailAddress requires its value to be RFC compliant by default. You can have it soft validate by setting the second attribute of the constructor to true.

new EmailAddress('email..@example.com') // => InvalidArgumentException
new EmailAddress('email..@example.com', true); // => OK