?
avatar ChrisDGFr
ChrisDGFr
25 Mar 2021

Steps to reproduce the issue

Reset Password form or Login reminder

Expected result

A mail is sent to the user.

Actual result

Announcement
Can't launch the mail function.

Error
Unable to send the e-mail.

System information (as much as possible)

Joomla! 3.9.21 and 3.9.25 on PHP 7.3.27.

Additional comments

I have configured Joomla to send mail with the mail() function. The test of sending mail works.
Sending "contact form" works.

This error appeared recently.

avatar ChrisDGFr ChrisDGFr - open - 25 Mar 2021
avatar joomla-cms-bot joomla-cms-bot - labeled - 25 Mar 2021
avatar saumyasarkar11
saumyasarkar11 - comment - 25 Mar 2021

Add [3.9] in the PR title

avatar richard67
richard67 - comment - 25 Mar 2021

Add [3.9] in the PR title

@saumyasarkar11 No, that's not necessary here. We only do that for issues specific to Joomla 4 or 3.10.

avatar saumyasarkar11
saumyasarkar11 - comment - 25 Mar 2021

Add [3.9] in the PR title

@saumyasarkar11 No, that's not necessary here. We only do that for issues specific to Joomla 4 or 3.10.

Ok, got it

avatar ChrisDGFr
ChrisDGFr - comment - 25 Mar 2021

Mail() works [in password reset] when sending from site@.fr to site@.fr
but not from site@.fr to @gmail.com


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32858.

avatar ChrisDGFr
ChrisDGFr - comment - 25 Mar 2021

Mail() works [in password reset] when sending from site@mySite.fr to site@mySite.fr
but not from site@mySite.fr to mySite@gmail.com


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32858.
avatar ChrisDGFr
ChrisDGFr - comment - 25 Mar 2021

Sending a Contact form works perfectly.screen shot 2021-03-25 at 17 50 29


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32858.

avatar ahotzler
ahotzler - comment - 25 Mar 2021

I tried to reproduce the problem, Joomla 3.9.25, PHP 7.3.27, PHP mail, Password Reminder "view=reset".

For me everything worked as expected

avatar PhilETaylor
PhilETaylor - comment - 28 Mar 2021

Mail() works [in password reset] when sending from site@mySite.fr to site@mySite.fr but not from site@mySite.fr to mySite@gmail.com

This sounds like your webhost doesn't allow relaying mail

ALL of Joomla's mail goes through the Mail Layer in Joomla, all emails are sent the same way. Therefore if the test mail works then all should work.

Can you try setting your email address in Joomla Global Config to the mySite@gmail.com email you are truing and attempt to send a test email to that email (not password reset - a test email using the Test Mail button.)

avatar ahotzler
ahotzler - comment - 28 Mar 2021

Mail() works [in password reset] when sending from site@mySite.fr to site@mySite.fr but not from site@mySite.fr to mySite@gmail.com

This sounds like your webhost doesn't allow relaying mail

Doesnt make sense, he wrote "The test of sending mail works."

avatar PhilETaylor
PhilETaylor - comment - 28 Mar 2021

Doesnt make sense, he wrote "The test of sending mail works."

The "The test of sending mail works." because he is sending from site@mySite.fr to site@mySite.fr

I want to know if it works sending to an OFF SERVER domain name like gmail.com

avatar ahotzler
ahotzler - comment - 28 Mar 2021

Ok, now i understand what you mean. Would such a behaviour end in: "Can't launch the mail function."?

avatar PhilETaylor
PhilETaylor - comment - 28 Mar 2021

In my testing.. yes.

avatar ahotzler
ahotzler - comment - 28 Mar 2021

Ok, thanks, I didn't expect that.

avatar ChrisDGFr
ChrisDGFr - comment - 31 Mar 2021

I added the statement "JLog::add('my error message', JLog::ERROR)" at the beginning of the PHPMailer::mailSend function.
I have a log when the function is called from a contact form, but not from the com_users module.
Bad luck!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32858.

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

Password reset uses:

		// Send the password reset request email.
		$return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $user->email, $subject, $body);

Contact form uses:

		$mail = JFactory::getMailer();
		$mail->addRecipient($contact->email_to);
		$mail->addReplyTo($email, $name);
		$mail->setSender(array($mailfrom, $fromname));
		$mail->setSubject($sitename . ': ' . $subject);
		$mail->setBody($body);
		$sent = $mail->Send();

The sendMail() method simple sets the params and then calls send method. So they are both using the same code eventually to send.

"Can't launch the mail function" is not a exact phrase used anywhere in Joomla or phpMailer so I assume that is translated. What is the exact phrase used in your language on the screen - send a screenshot.

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

Also please run this test:

Can you try setting your email address in Joomla Global Config to the mySite@gmail.com email you are truing and attempt to send a test email to that email (not password reset - a test email using the Test Mail button.)

Im still convinced this is a hosting issue.

avatar ChrisDGFr
ChrisDGFr - comment - 31 Mar 2021

That is the exact phrase.
Image 111

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

Well that is being raised by phpMailer when it cannot send using the linux mail function (E.g a web hosting issue) Do you have safe_mode enabled in PHP?

throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL);

The actual mail command is in this function on lines 700 and 702 of libraries/vendor/phpmailer/phpmailer/class.phpmailer.php, So remove the error suppressor @ before the word @mail and then repeat your tests with error reporting set to development/maximum in Joomla global Config and debug mode on and see if any further error is output now that the command is not suppressed.

private function mailPassthru($to, $subject, $body, $header, $params)

    private function mailPassthru($to, $subject, $body, $header, $params)
    {
        //Check overloading of mail function to avoid double-encoding
        if (ini_get('mbstring.func_overload') & 1) {
            $subject = $this->secureHeader($subject);
        } else {
            $subject = $this->encodeHeader($this->secureHeader($subject));
        }

        //Can't use additional_parameters in safe_mode, calling mail() with null params breaks
        //@link http://php.net/manual/en/function.mail.php
        if (ini_get('safe_mode') or !$this->UseSendmailOptions or is_null($params)) {
            $result = mail($to, $subject, $body, $header);
        } else {
            $result = mail($to, $subject, $body, $header, $params);
        }
        return $result;
    }
avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

Also try running mail independently of Joomla by creating a test.php file with this in it:

<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
mail('youremail@gmail.com','subject','test');

and then run that and see if there are any errors.

avatar ChrisDGFr
ChrisDGFr - comment - 31 Mar 2021

I think I found the problem.

Works :

From email : site@mySite.fr
Reply to email : site@mySite.fr

Do not work :

From email : site@mySite.fr
Reply to email : mySite@gmail.com

From email : mySite@gmail.com
Reply to email : mySite@gmail.com

It seems that com_users takes "Reply to email" as "From email".

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

Cough Cough. This is not a Joomla/phpMailer issue. This is a hosting issue.

Im still convinced this is a hosting issue.

This sounds like your webhost doesn't allow relaying mail

avatar ChrisDGFr
ChrisDGFr - comment - 31 Mar 2021

It seems normal that the site mySite.fr can not send mail from the domain gmail.com.

avatar ChrisDGFr
ChrisDGFr - comment - 31 Mar 2021

Com_users should use the sender designated to it: site@mySite.fr.

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

It does. It uses the $mailfrom value from global config.

$data['mailfrom'] = $config->get('mailfrom');

avatar ChrisDGFr
ChrisDGFr - comment - 31 Mar 2021

How do you explain that :

Works :

From email : site@mySite.fr
Reply to email : site@mySite.fr

Do not works :

From email : site@mySite.fr
Reply to email : mySite@gmail.com

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

I do not know who your site is configured. I do know what the code states.

What are the VALUES you have set in your Joomla global Configuration?

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

From email : site@mySite.fr

If that is the value in your Joomla Global Config for the Mail Sending - So Joomla is correctly using the same FROM address. And correctly changing the Reply from address on emails that might need a reply, and your webhost is rejecting those - because that's also what spammers do.

I see nothing that needs fixing here in Joomla.

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

This error appeared recently.

Code doesn't change :) webhost configurations and spam controls change :-)

avatar ChrisDGFr
ChrisDGFr - comment - 31 Mar 2021

Here are pictures of the different configurations and their consequences.
Image 116
Image 119
Image 122

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

image

So your failure is failing to send using the mail function on your webhost, an email FROM a gmail.com address ... again, this is your webhost probably stopping you with spam controls on what addresses you can send from with PHP Mail. This is totally normal for a webhost to stop spamming this way.

If you want to use your gmail.com account email as the sender or reply, then use SMTP mail (which has better debugging and error messages) and even configure it to send mail using the Gmail SMTP servers.

avatar ChrisDGFr
ChrisDGFr - comment - 31 Mar 2021

You know what, I am going to add a Forwarder from site@clapiedsrando.fr to clapiedsrando@gmail.com.

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

Run this as a test

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$to      = 'clapiedsrando@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: clapiedsrando@gmail.com' . "\r\n" . 'Reply-To: clapiedsrando@gmail.com' . "\r\n";

mail($to, $subject, $message, $headers);
avatar ChrisDGFr
ChrisDGFr - comment - 31 Mar 2021

The difference between image 1 (success) and image 2 (failure) is not "From email" but "Reply to Email".

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

Correct. I know that. But you are not listening. This is not Joomla's fault if your webhost is blocking you from having a Gmail address in the headers.

RUN THE TEST I have asked you to and report if it works or errors please.

avatar ahotzler
ahotzler - comment - 31 Mar 2021

...

So your failure is failing to send using the mail function on your webhost, an email FROM a gmail.com address ... again, this is your webhost probably stopping you with spam controls on what addresses you can send from with PHP Mail. This is totally normal for a webhost to stop spamming this way.

If you want to use your gmail.com account email as the sender or reply, then use SMTP mail (which has better debugging and error messages) and even configure it to send mail using the Gmail SMTP servers.

What Phil says is correct. The whole discussion has become completely pointless.

avatar alikon alikon - change - 31 Mar 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-03-31 18:38:02
Closed_By alikon
avatar alikon alikon - close - 31 Mar 2021
avatar alikon
alikon - comment - 31 Mar 2021

matter for https://forum.joomla.org/ imho

avatar PhilETaylor
PhilETaylor - comment - 31 Mar 2021

I tried to help :)

avatar richard67
richard67 - comment - 31 Mar 2021

I tried to help :)

@PhilETaylor You could have fixed 5 bugs in the mean time ?

Add a Comment

Login with GitHub to post a comment