Some few examples below provides a better insight to how this is done.
Sample: Authorizing mails
<?php
$mailer = new Mailer;
... //other codes here
$mailer->content('mail.template'); // can be defined in $mailer->sendmail()
$mailer->authorize(true);
if($mailer->authorized()){
$mailer->sendmail(); // returns true if configuration parameters are set and mail attempted
}
Note: when authorized, the
sendmail() returns true only if the mail is successfully
configured and an attempt is made to forward the mail.
However, when authorize(false) is used, the sendmail returns true only if the configuration
parameters are set. The example below reveals this.
The
sendmail() method is not a true way of checking if mail is
successfully sent. This should be handled using the sent() method.
The authorize() method can be harvested to only send mails online by
using the online constant which returns true on live environment. An example
is shown below: