My-Little-Forum / mylittleforum

A simple PHP and MySQL based internet forum that displays the messages in classical threaded view (tree structure)
GNU General Public License v3.0
124 stars 48 forks source link

email is not send when user register, change email address, in general no email is going from the site! #683

Closed paulasijit closed 9 months ago

paulasijit commented 1 year ago

Here is the config for php_mailer.php

<?php
if (!defined('IN_INDEX')) {
    header('Location: ../index.php');
    exit;
}

/** config for PHPMailer **/
// Please read https://github.com/PHPMailer/PHPMailer/blob/master/src/PHPMailer.php 
// for further configuration properties
$PHP_MAILER_CONFIG = array(
    'Mailer'        => 'smtp',              // 'smtp', 'mail', 'sendmail' or 'qmail'
    'Port'          => '587',               // well-known ports are 25 (default), 587 (TLS) or 465 (SSL)
    'SMTPSecure'    => 'tls',               // '', 'tls' or 'ssl'
    'ContentType'   => 'text/plain',        // 'text/plain' or 'text/html'
    'Encoding'      => 'quoted-printable',  // '8bit', '7bit', 'binary', 'base64', and 'quoted-printable'
    'CharSet'       => 'utf-8',             // 'iso-8859-1' or 'utf-8'
    'SMTPAuth'      => true,                // true, for SMTP authentication via username/password
    'Host'          => 'smtpout.secureserver.net',      
    'Username'      => '', 
    'Password'      => ''           
);
/** config for PHPMailer **/
?>
loesler commented 1 year ago

Hej,

do you really use the PHPMailer, i.e., do you enable this feature?

/Micha

paulasijit commented 1 year ago

I have used a custom script using the same phpmailer and was able to send the email, but the same configuration was not working on the mylittleforum.

Or do I need to enable something from the mylittleforum config to use it?

loesler commented 1 year ago

Hello,

Or do I need to enable something from the mylittleforum config to use it?

Yes, the option php_mailer should be enabled otherwise PHPs mail() function is used.

/Micha

paulasijit commented 1 year ago

Yes its enabled and I have tested it with an custom test script it’s working fine.

loesler commented 1 year ago

Is the problem solved? If so, I will close this issue.

paulasijit commented 1 year ago

no this is not solved i am able to send email using this code but not the mylittleforum code

elseif ( $_REQUEST['sendmethod'] == "smtp" ) {
        ob_start(); //start capturing output buffer because we want to change output to html

        $mail = new PHPMailer;

        $mail->SMTPDebug = 2;
        $mail->IsSMTP();
        if ( strpos($hostname, 'cpnl') === FALSE ) //if not cPanel
            $mail->Host = 'relay-hosting.secureserver.net';
        else
            $mail->Host = 'localhost';
        $mail->SMTPAuth = false;

        $mail->From = $from;
        $mail->FromName = 'Mailer';
        $mail->AddAddress($toemail);

        $mail->Subject = $subject;
        $mail->Body = $message;

        $mailresult = $mail->Send();
        $mailconversation = nl2br(htmlspecialchars(ob_get_clean())); //captures the output of PHPMailer and htmlizes it
        if ( !$mailresult ) {
            echo 'FAIL: ' . $mail->ErrorInfo . '<br />' . $mailconversation;
        } else {
            echo $mailconversation;
        }
    }
loesler commented 1 year ago

Hello,

I am sorry, but I am not able to reproduce your problem. I have switched to PHPMailer and it works as expected.

2023-11-26 09:25:15 SERVER -> CLIENT: 250 2.0.0 Ok: queued as 123B8240044
2023-11-26 09:25:15 CLIENT -> SERVER: QUIT
2023-11-26 09:25:15 SERVER -> CLIENT: 221 2.0.0 Bye

Maybe you can check the $PHP_MAILER->ErrorInfo, i.e.:

$PHP_MAILER->SMTPDebug = 2; // Log-Level: 1, 2,3 4
echo $PHP_MAILER->ErrorInfo;
exit;

/Micha

loesler commented 9 months ago

No further comment since Nov 26, thus, I close the issue.