Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email send fails when using phpmail/sendmail on some servers #43485

Open
ron4mac opened this issue May 18, 2024 · 1 comment
Open

Email send fails when using phpmail/sendmail on some servers #43485

ron4mac opened this issue May 18, 2024 · 1 comment

Comments

@ron4mac
Copy link
Contributor

ron4mac commented May 18, 2024

Steps to reproduce the issue

Set Joomla instance to use PHP Mail or Sendmail.
Perform some activity that causes email to be sent (registration, contact).

Expected result

Generated email is sent without issue

Actual result

Error: Could not instantiate mail function.

System information (as much as possible)

Joomla 4 or 5 on Siteground hosting

Additional comments

Some systems fail when attempting to send email which has the recipient name and email set to the same value (501 error).

libraries/src/Mail/MailTemplate.php

* @since   4.0.0
*/
 public function addRecipient($mail, $name = null, $type = 'to')
 {
     $recipient          = new \stdClass();
     $recipient->mail    = $mail;
     $recipient->name    = $name ?? $mail;    <<<<==== 
     $recipient->type    = $type;
     $this->recipients[] = $recipient;
}

addRecipient() is often called with only an email address, which causes the name to be set to the same as email.
This is causing failure on some servers (or their mail servers).

Possible workaround

$recipient->name = $name ?? strstr($mail,'@',true);

Additional preferable solution

All Joomla calls to this addRecipient() method provide an appropriate name argument.

@Fedik
Copy link
Member

Fedik commented May 18, 2024

It is kind of server protection from users who trying to send spam.
I think Joomla should not try to set a name if it not provided, it is totally fine to have only an email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants