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

Identify

'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.

Monstra 3.0.1

fadlisaad's Website

Re: Enable SMTP support for Contact Plugin

I did that, and while I click "send" button after filling the form fields - my server is loading for a long time, and after that I am getting this message "405 Not Allowed"

Re: Enable SMTP support for Contact Plugin

I think is a bug that has been reported to phpmailer. You may want to refer to this post and try to relate if it is similar to your error.

http://sourceforge.net/p/phpmailer/bugs/405/

Monstra 3.0.1

fadlisaad's Website

Re: Enable SMTP support for Contact Plugin

Putting
sleep(10);
in the class.smtp.php file, immediately before
if(empty($this->smtp_conn)) 

I don't have a such line inside class.smtp.php (well, in my smtp.php -- following Your upper steps).

Re: Enable SMTP support for Contact Plugin

The server version might be a issue also! wink

http://monstracreative.com - themes, plugins and snippets for monstra cms

:: ATTENTION ::
Need help? Login at your account at: http://monstracreative.com/users/login. -> You have a excellent support center at our website! wink

wormsunited's Website