setup() method is used to load the default setup either as an array or a file.
setup()
method. The method accepts the filename or file path by using the dot convention. for example, a file path of
mail/server.php will be supplied as mail.server . This makes it easier to load the server
config file.
Sample Server File Configuration (server.php)
<?php
return [
'SMTPAuth' => true, // Enable SMTP authentication
'Host' => 'smtp.mail.com', // Specify main and backup SMTP servers smtp.gmail.com / website hostname
'Username' => 'info@site.com', // SMTP username e.g info@site.com..
'Password' => '123abc', // SMTP password ..
'SMTPSecure' => 'tls', // Enable TLS encryption, PHPMailer::ENCRYPTION_STARTTLS`PHPMailer::ENCRYPTION_SMTPS`
'Port' => 587, // TCP port to connect to (mostly constant)
];
Sample: Loading Server File
<?php
$mailer = new Mailer;
$mailer->server('server'); // e.g server.php
server() method.
Sample: Server Array Configuration / Modification
<?php
$mailer = new Mailer;
// loading array directly
$mailer->server([
'SMTPAuth' => true, // Enable SMTP authentication
'Host' => 'smtp.mail.com', // Specify main and backup SMTP servers smtp.gmail.com / website hostname
'Username' => 'info@site.com', // SMTP username e.g info@site.com..
'Password' => '123abc', // SMTP password ..
'SMTPSecure' => 'tls', // Enable TLS encryption, PHPMailer::ENCRYPTION_STARTTLS`PHPMailer::ENCRYPTION_SMTPS`
'Port' => 587, // TCP port to connect to (mostly constant)
]);
It is however import to note that the array method overides any default configuration set.