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

Bugfix mail from must equal authorized user when sending email reports #14137

Closed
wants to merge 4 commits into from

Conversation

frankgx97
Copy link

fix #12426

Hi there,

For some email providers (eg. qq.com, exmail.qq.com), sending emails via smtp without providing "from address" will get the "mail from must equal authorized user" error.

2019-02-25 9 12 02

Though PR #8454 added "noreply_email_address" and "noreply_email_name" field to the config file, it placed these fields to the "General" section, instead of "mail" section, which is misleading. And it cannot be set from the General Settings page.

I moved the two options to the "mail" section of the config file, and added "SMTP from address" and "SMTP from name" to the General Settings page to enable users to configure these two fields from the Settings page.

Regards.

<div piwik-field uicontrol="text" name="mailFromAddress"
ng-model="mailSettings.mailFromAddress"
title="{{ 'General_SmtpFromAddress'|translate|e('html_attr') }}"
value="{{ mail.noreply_email_address }}" inline-help="{{ 'General_UsuallyYourEmailAddress'|translate|e('html_attr') }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure but it may need to be {{ mail.noreply_email_address|e('html_attr') }} to escape it re security

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same probably for the other fields above that were already defined

<div piwik-field uicontrol="text" name="mailFromName"
ng-model="mailSettings.mailFromName"
title="{{ 'General_SmtpFromName'|translate|e('html_attr') }}"
value="{{ mail.noreply_email_name }}" inline-help="{{ 'General_NameShownInTheSenderColumn'|translate|e('html_attr') }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure but it may need to be {{ mail.noreply_email_name |e('html_attr') }} to escape it re security

$fromEmailName = Config::getInstance()->General['noreply_email_name'];
$fromEmailName = Config::getInstance()->mail['noreply_email_name'];
if(empty($fromEmailName)){
$fromEmailName = Config::getInstance()->General['noreply_email_name'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon it might be better to create an update script using the command ./console generate:update --component=core to migrate both config settings from General to mail within the doUpdate() method. This way it will be easier to change the value for users in the future (by directly seeing the default value noreply@{DOMAIN}) and it won't be defined in 2 places (less confusion).

You can see an example here: https://github.com/matomo-org/matomo/blob/3.x-dev/core/Updates/2.15.0-b12.php#L25-L41

This means you can set the default value of noreply@{DOMAIN} for [mail]noreply...

@tsteur
Copy link
Member

tsteur commented Apr 11, 2019

Thanks for this @nyanim 👍 very appreciated. Left a comment in the PR

@mattab mattab added this to the 3.11.0 milestone Jun 10, 2019
@mattab mattab added the Needs Review PRs that need a code review label Jun 10, 2019
@@ -869,6 +869,8 @@
username = ; SMTP username
password = ; SMTP password
encryption = ; SMTP transport-layer encryption, either 'ssl', 'tls', or empty (i.e., none).
noreply_email_address = ; standard email address displayed when sending emails
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will also need to remove these settings from the General section

@@ -292,6 +292,8 @@
"OneVisit": "1 次访问",
"OnlyEnterIfRequired": "在您的 SMTP 服务器需要用户名时才需要输入",
"OnlyEnterIfRequiredPassword": "在您的 SMTP 服务器需要密码时才需要输入",
"UsuallyYourEmailAddress": "通常是您的Email地址",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we can only include english default translations. Other languages will need to be translated through our translation tool see https://matomo.org/translations

@mattab mattab modified the milestones: 3.11.0, 3.12.0 Jul 23, 2019
@mattab mattab added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label Jul 27, 2019
@katebutler
Copy link

Duplicate of #14975

@katebutler katebutler marked this as a duplicate of #14975 Oct 9, 2019
@katebutler katebutler closed this Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mail from must equal authorized user
4 participants