shadiakiki1986 / swiftmailer-wrapper
wrapper function for swiftmailer
Installs: 1 218
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 1
Requires
- php: >=5.3.5
- swiftmailer/swiftmailer: ^6
Requires (Dev)
- php: >=7
- jakub-onderka/php-parallel-lint: ^0.9
- phpunit/phpunit: ^5.6
README
Wrapper function for using Swiftmailer (in php)
Available on packagist
Install: composer require shadiakiki1986/swiftmailer-wrapper:dev-master
Use:
require_once __DIR__.'/vendor/autoload.php'; \SwiftmailerWrapper\Utils::mail_attachment( // attachments array("/path/to/file1","/path/to/file2"), // to, from, reply emails "to@email.com", "from@email.com", "From Name", "reply@email.com", // subject, body "This is a subject", "This is a message. It <i>supports</i> html.", // config array array( "host"=>"smtp.server.com", "port"=>"123", "username"=>"myUser", "password"=>"pizza" ) );
Files can be renamed in attachment by passing files parameter as follows:
array("newName1"=>"/path/to/file1","newName2"=>"/path/to/file2"),
To use encrypted smtp, add security
key to the config array. Valid values are: false, ssl, tls
To add a backup SMTP server and credentials, add a backup
key similar to the original config array, i.e. with host, port, username, password, security
.
Testing
composer install
SWIFTMAILER_WRAPPER_EML1=my@gmail.com \
SWIFTMAILER_WRAPPER_PWD1=password1 \
SWIFTMAILER_WRAPPER_EML2=another@gmail.com \
SWIFTMAILER_WRAPPER_PWD2=password2 \
composer test
Note that emails above should be gmail accounts because the tests define the gmail server explicitly