yf_test_smtp_phpmailer user module

Fileplugins/test/modules/test/yf_test_smtp_phpmailer.class.php
Usemodule('test_smtp_phpmailer'), URL ?object=test_smtp_phpmailer

Public properties

PropertyDefaultDescription
None declared in this class.

Public methods 1

test

public function test()
    public function test()
    {
        $error_message = $body = null;
        $time_start = microtime(true);

        require_php_lib('phpmailer');
        $mail = new PHPMailer();

        $mail->IsSMTP();
        $mail->Host = module('test')->SMTP_OPTIONS['smtp_host'];
        $mail->SMTPAuth = true;
        $mail->Username = module('test')->SMTP_OPTIONS['smtp_user_name'];
        $mail->Password = module('test')->SMTP_OPTIONS['smtp_password'];
        if (module('test')->SMTP_OPTIONS['smtp_secure']) {
            $mail->SMTPSecure = module('test')->SMTP_OPTIONS['smtp_secure'];
        }

        $mail->From = module('test')->TEST_MAIL['email_from'];
        if (module('test')->TEST_MAIL['name_from']) {
            $mail->FromName = module('test')->TEST_MAIL['name_from'];
        }
        $mail->AddAddress(module('test')->TEST_MAIL['email_to'], module('test')->TEST_MAIL['name_to']);
        $mail->IsHTML(true);

        $mail->Subject = module('test')->TEST_MAIL['subject'];
        $mail->Body = module('test')->TEST_MAIL['html'];
        $mail->AltBody = module('test')->TEST_MAIL['text'];

        $result = $mail->Send();
        $error_message = $mail->ErrorInfo;

        $body = $result ? '<b style="color:green;">Send successful</b>' : '<b style="color:red;">Send failed</b>';
        $body .= ! $result ? '<br /><b>Reason:</b><br /> ' . $error_message . '<br />' : '';
        $body .= '<br />Spent time: ' . common()->_format_time_value(microtime(true) - $time_start) . ' sec.<br />';
        return $body;
    }