<?php require_once '../vendor/autoload.php'; require_once '../iMailRecipient.php'; require_once '../MailRecipient.php'; require_once '../iMail.php'; require_once '../Mail.php'; $smtp_options = array('host' => 'smtp.domain.com', 'secure' => 'tls', 'port' => 587, 'username' => '*****@*****.**', 'password' => 'secret_password'); $mailer = new Nette\Mail\SmtpMailer($smtp_options); $mail = new Emailing\Mail($mailer); $mail->setSubject('Sending in batch'); $mail->setTextBody('This mail was sent in batches'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->send(1);
* Fake logging class - here just prints */ class FakeLogger { private static $levels = array(LOG_EMERG => 'EMERGENCY', LOG_ALERT => 'ALERT', LOG_CRIT => 'CRITICAL', LOG_ERR => 'ERROR', LOG_WARNING => 'WARNING', LOG_NOTICE => 'NOTICE', LOG_INFO => 'INFO', LOG_DEBUG => 'DEBUG'); public function log($level, $msg) { echo self::$levels[$level] . ': ' . $msg . PHP_EOL; } } require_once '../vendor/autoload.php'; require_once '../iMailRecipient.php'; require_once '../MailRecipient.php'; require_once '../iMail.php'; require_once '../Mail.php'; $smtp_options = array('host' => 'smtp.domain.com', 'secure' => 'tls', 'port' => 587, 'username' => '*****@*****.**', 'password' => 'secret_password'); $mailer = new Nette\Mail\SmtpMailer($smtp_options); $mail = new Emailing\Mail($mailer); /** optional - only for logging purposes */ $logger = new FakeLogger(); $mail->setLogger(array($logger, 'log')); /** minimum level to log */ $mail->setLogLimit(LOG_INFO); $mail->setSubject('Sending in batch'); $mail->setTextBody('This mail was sent in batches'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->send(1);
<?php require_once '../vendor/autoload.php'; require_once '../iMailRecipient.php'; require_once '../MailRecipient.php'; require_once '../iMail.php'; require_once '../Mail.php'; require_once '../iStorage.php'; require_once '../MySQLStorage.php'; // build a mail $smtp_options = array('host' => 'smtp.domain.com', 'secure' => 'tls', 'port' => 587, 'username' => '*****@*****.**', 'password' => 'secret_password'); $mailer = new Nette\Mail\SmtpMailer($smtp_options); $mail = new Emailing\Mail($mailer); $mail->setName('Expample of using mail storage'); $mail->setSubject('Sending in batch'); $mail->setTextBody('This mail was sent in batches'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); // save it with MySQL storage $db = new mysqli('localhost', 'root', 'p4ssw0rd', 'test'); $storage = new \Emailing\MySQLStorage($db); $storage->setPrefix('emailing'); // use this to create necessary tables // $storage->install(true); $storage->save($mail);