Asatru PHP Documentation


Project maintained by asatru-php Hosted on GitHub Pages — Theme by mattgraham

SMTP mailing

The framework provides an interface to the PHPMailer package. Like the mail() wrapper you can send HTML content by specifying views. Except it uses SMTP protocol to send mails. This requires an SMTP service running on a server.

The following environment variables need to be adjusted:

The following example demonstrates how to use the functionality

<?php

//Instantiate class instance
$mailer = new Asatru\SMTPMailer\SMTPMailer();

//Here you set the recipient of the e-mail
$mailer->setRecipient('receiver@example.com');

//E-Mail subject
$mailer->setSubject('E-Mail subject');

//Specify a view
$mailer->setView('layout', array(array('yield', 'yieldfile')), [
    'some_var' => $some_value
]);

//Or directly set message content:
$mailer->setMessage($content);

//Used to specify further properties for the current PHPMailer instance. Does overwrite properties previously set by other methods.
$mailer->setProperties([]);

$mailer->send(); //Send the e-mail

Of course you can directly access PHPMailer class for custom e-mailing.