php mail() function in PHPBB3 - alternative to SMTP

-1

Problem with the php mail() function in PHPBB3

Hi, my board is a phpbb 3.3.0

my phpinfo: http://www.raptormaniaforum.it/phpinfo.php

About sending emails from my board, my hosting disabled the use of SMTP (localhost) and told me to switch to the native php mail() function. I changed the configuration within my PHPBB ADMIN panel but when i try to send an email I get this error:

E-MAIL ERROR
» EMAIL/PHP/mail()

I supposed it was caused by the hosting blocking the mail() function but they told me it is working, and I verified this using this simple php test page, which actually is working fine:

<?php

$txt = "body test email";
// Send email
mail("mymail@mymail.it","test subject",$txt);
?>

I noticed that the mail() function is wrapped in the file includes/functions_messenger.php

/**

* Wrapper for sending out emails with the PHP's mail function
*/
function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg)
{
    global $config, $phpbb_root_path, $phpEx;

    // We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used...
    // Reference: http://bugs.php.net/bug.php?id=15841
    $headers = implode($eol, $headers);

    if (!class_exists('phpbb_error_collector'))
    {
        include($phpbb_root_path . 'includes/error_collector.' . $phpEx);
    }

    $collector = new phpbb_error_collector;
    $collector->install();

    // On some PHP Versions mail() *may* fail if there are newlines within the subject.
    // Newlines are used as a delimiter for lines in mail_encode() according to RFC 2045 section 6.8.
    // Because PHP can't decide what is wanted we revert back to the non-RFC-compliant way of separating by one space (Use '' as parameter to mail_encode() results in SPACE used)
    $result = $config['email_function_name']($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers);

    $collector->uninstall();
    $err_msg = $collector->format_errors();

    return $result;
}

what I kindly ask you is: 1-how can I display onscreen or in the error logs the content of the variable "$result;"?

2-I noticed this alert: "// On some PHP Versions mail() may fail if there are newlines within the subject." How can I check if this is the problem?

  1. What about the idea of switching to SMTP - that runs with Gmail. Do we can use of some general data to connect to the google servers

love to hear from

misterpope

Posted 2020-02-28T15:29:36.097

Reputation: 1

Question was closed 2020-02-28T15:44:47.873

Programming questions are off topic here and should be asked on [so]. – Mokubai – 2020-02-28T15:44:55.507

No answers