Reset Password form or Login reminder
A mail is sent to the user.
Announcement
Can't launch the mail function.
Error
Unable to send the e-mail.
Joomla! 3.9.21 and 3.9.25 on PHP 7.3.27.
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.
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.
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
Mail() works [in password reset] when sending from site@.fr to site@.fr
but not from site@.fr to @gmail.com
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
Sending a Contact form works perfectly.
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
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.)
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."
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
Ok, now i understand what you mean. Would such a behaviour end in: "Can't launch the mail function."?
In my testing.. yes.
Ok, thanks, I didn't expect that.
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!
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.
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.
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?
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)
{
//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;
}
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.
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".
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
It seems normal that the site mySite.fr can not send mail from the domain gmail.com.
Com_users should use the sender designated to it: site@mySite.fr.
It does. It uses the $mailfrom
value from global config.
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
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?
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.
This error appeared recently.
Code doesn't change :) webhost configurations and spam controls change :-)
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.
You know what, I am going to add a Forwarder from site@clapiedsrando.fr to clapiedsrando@gmail.com.
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);
The difference between image 1 (success) and image 2 (failure) is not "From email" but "Reply to Email".
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.
...
So your failure is failing to send using the
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.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-03-31 18:38:02 |
Closed_By | ⇒ | alikon |
matter for https://forum.joomla.org/ imho
I tried to help :)
I tried to help :)
@PhilETaylor You could have fixed 5 bugs in the mean time
Add [3.9] in the PR title