shippinno / email
Installs: 2 049
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 5
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
- egulias/email-validator: ^2.1
- psr/log: ^1.0
- swiftmailer/swiftmailer: ^5.3|^6.0
- tanigami/value-objects: ^0.4.6
Requires (Dev)
- mockery/mockery: ^1.2
- phpunit/phpunit: ^7.4
This package is not auto-updated.
Last update: 2024-12-20 22:18:39 UTC
README
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