Send Mail

YeeBase send email using sendMail() function in yeebase\extensions\ysUtil\ysUtil.php. This extensions override base on composer package \Exiang\YsUtil\YsUtil.

Sending using ysUtil::sendMail()

$receivers[] = array('email' => 'receiver@yahoo.com', 'name' => 'Receiver Name');

$subject = 'Try sending email using ysUtil::sendMail function';
$htmlString = '<h2>Lorem ipsum dolor sit amet</h2><p><b>consectetur</b> adipiscing elit:</p><ol><li><a href="http://www.wikipedia.com">Wikipedia</a></li><li>Google</li><li>Yahoo</li></ol>';

// send thru extension `yeebase\extensions\ysUtil`
$result = ysUtil::sendMail($receivers, $subject, $htmlString);

if ($result === true) {
    // mail sent successfully
}

Sending using template

Using a template make sure all your outgoing mails have a consistent branding layout.

$receivers[] = array('email' => 'receiver@yahoo.com', 'name' => 'Receiver Name');

$subject = 'Try sending email using ysUtil::sendTemplateMail function';
$htmlString = '<h2>Lorem ipsum dolor sit amet</h2><p><b>consectetur</b> adipiscing elit:</p><ol><li><a href="http://www.wikipedia.com">Wikipedia</a></li><li>Google</li><li>Yahoo</li></ol>';
$result = ysUtil::sendTemplateMail($receivers, $subject, array('message' => $htmlString));

if ($result === true) {
    // mail sent successfully
}

Internally, this is what make it works:

Sending bulk in one single SMTP call

Using a transaction mail provider like MailGun allow you to send multiple mails in one single SMTP call thru custom variable passed in at mail header.

More

You can also choose to send thru PHPMailer without going thru YsUtil, more example of various send mail methods can be found at https://domain.com/egg/egg/mail

Last updated

Was this helpful?