Being a web developer I often need to send emails based on user requirements, some time these are simple emails but some times users want to take control of email contents and attachments.
To make it easier for me and other developers I have created a mail library which can be easily switched to php native mail() function or smtp backend.
For smtp it is using swiftmailer and phpmailer, you can configure any of these as your smtp backend, by default swiftmailer is enabled as default smtp sender.
How to use library
Please download the library from gitub at following location
you can git clone or download to your project directory
create mail sender script
//index.php require_once 'Tecnotch/bootstrap.php'; use Tecnotch; $mailer = TecnotchFactory::mailer('simple'); //keep them in order as they are below $placeholders = array( "[user_name]" => "John Doe" ); $mailer ->setPlaceholders($placeholders) ->setTemplatePath(__DIR__ . '/html/email/en') ->setTemplate("sample.html") ->setTo(array("email@example.com" => "Tofeeq Rehman", "firstname.lastname@example.org" => "Tof33q")) ->setCc(array("email@example.com" => "Tofeeq Testing", "firstname.lastname@example.org" => "Dev Tofeeq")) ->setFrom(array("email@example.com" => "Tecnotch")) ->setReplyTo(array("firstname.lastname@example.org" => "Tecnotch-Suport")) ->addAttachment(__DIR__ . '/test1.pdf', 'Test PDF 1', 'pdf') ->addAttachment(__DIR__ . '/test2.pdf', 'Test PDF 2', 'pdf') ->addAttachment(__DIR__ . '/test3.pdf', 'Test PDF 3', 'pdf') ->send();
You can read further examples and documentation on Github page