PHP code example of praetoriantechnology / smart-mailer
1. Go to this page and download the library: Download praetoriantechnology/smart-mailer library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
praetoriantechnology / smart-mailer example snippets
declare(strict_types=1);
use Praetorian\SmartMailer\Attachment;
use Praetorian\SmartMailer\EmailAddress;
use Praetorian\SmartMailer\Message;
use Praetorian\SmartMailer\SmartMailer;
use Praetorian\SmartMailer\Smtp;
me('username')
->setPassword('password')
;
$image1 = new Attachment();
$image1->setPath('sample.png')
;
$message = new Message();
$message->setFrom($from)
->addTo($to)
->setHtml('<html><head><title>test</title></head><body>{{ variable }} <img src="cid:sample.png" alt="test"/></body></html>')
->addImage($image1)
->setSubject('sample mail title')
->setContext([
'variable' => 'sample text',
])
;
$mailer = new SmartMailer($smtp);
$mailer->send($message);
$image1->setName('othername')