Package for send mails.
Send one message by the PHP function mail()
use Sendmail\Message;
use Sendmail\Sender\Mail;
$message = new Message();
$message
->setTo('[email protected]')
->setSubject('Example subject')
->setText('Example message');
$sender = new Mail();
$sender->send($message);
Connect to SMTP server and push mails into him
use Sendmail\Queue;
use Sendmail\Message;
use Sendmail\Sender\Smtp;
use Sendmail\Sender\Smtp\Exception;
$message1 = new Message();
$message1
->setTo('[email protected]')
->setSubject('Example subject 1')
->setText('Example message 1')
// email of the sender
->setFrom('[email protected]', 'Sender');
$message2 = clone $message1;
$message2
->setTo('[email protected]')
->setSubject('Example subject 2')
->setText('Example message 2');
// sending messages to the queue via a direct connection to the SMTP server
$queue = new Queue(new Smtp('example.com', 25, 'username', 'password'));
$queue
->add($message1)
->add($message2);
try {
// send all messages
var_dump($queue->send());
} catch (Exception $e) {
// SMTP dialogue
echo $e->getDialogue()->getLog();
}
$queue->clear();
use Sendmail\Queue;
use Sendmail\Message;
use Sendmail\Sender\Mail;
$message = new Message();
$message
->setSubject('Example subject')
->setText('<h1>Example message.<h1><p>You can remove this message.</p>')
// email of the sender
->setFrom('[email protected]')
// send email in HTML format
->inHTML();
$queue = new Queue(new Mail());
// add to queue a letter addressed to multiple recipients
$queue->notify(
array(
'[email protected]',
'[email protected]',
'[email protected]'
),
$message
);
$queue->send();
$queue->clear();