Topic: Enable SMTP support for Contact Plugin
This post is to show you how to enable SMTP support while using the Contact plugin. By default, the plugin is set to use mail() or sendmail(), with normally can be used directly with zero configuration. However, SMTP classes were not included, thus while trying to use it with SMTP relay/server, it will throw SMTP class not found error.
To solve this issue, you need to follow these simple step, but it will require you to modify the core Monstra file.
Download the latest PHPMailer package from https://github.com/Synchro/PHPMailer. This is a fork from the original PHPMailer.
Choose only two file required: class.phpmailer.php and class.smtp.php
Rename both file to PHPMailer.php and SMTP.php respectively.
Copy both file to the original PHPMailer libraries. The path is monstra/libraries/PHPMailer. This will replace the original PHPMailer.php file, as for
SMTP class to work, it will need the same version for both file.
Next, edit the core Monsta file at monsta/engine/Monsta.php
'PHPMailer' => ROOT . DS .'libraries'. DS . 'PHPMailer'. DS .'PHPMailer.php',
and add these line after it:
'SMTP' => ROOT . DS .'libraries'. DS . 'PHPMailer'. DS .'SMTP.php',
The modified line should be as below:
'PHPMailer' => ROOT . DS .'libraries'. DS . 'PHPMailer'. DS .'PHPMailer.php', 'SMTP' => ROOT . DS .'libraries'. DS . 'PHPMailer'. DS .'SMTP.php',
Locate the plugin at monstra/plugins/contact/contact.plugin.php and add these line:
$mail->IsSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 2; $mail->Host = "smtp.some-server.com"; $mail->Port = 25;
Test your configuration and see if there is any problem, you may need to check with the SMTP server.