Skip to main content
Version: Fegg 5.x

Mail::setDebugFlag

Write mails to a log file instead of sending them

Description​

public self Mail::setDebugFlag( boolean $is_debug, [ string $log_name = null ] )

When $is_debug is true, Mail::send does not send the email but writes the whole message to the log file: $log_name, or mail.log in the log directory when it is not given (htdocs/_fegg/site/data/log/mail.log, or the directory of FEGG_LOG_DIR). Mail::logFile returns the file used.

Arguments​

NameData typeDefaultRemarks
$is_debugbooleantrue: write a log instead of sending
$log_namestringnullLog file path (none: mail.log in the log directory)

Example​

Controller
use Fegg\Tool\Mail;

$mail = new Mail('Mail subject', 'Mail body');
$mail->setDebugFlag(true); // site/data/log/mail.log
$mail->setDebugFlag(true, FEGG_SITE_DIR . '/data/log/contact_admin.log'); // another file

// Written to the log file instead of being sent
$mail->send('mail@example.com', 'John Doe', 'from@example.com');