@Back-Sephiroth opened this Issue on March 16th 2015


The scheduling report never gone in my mail-box, my FAI orange reject the mail, perhaps the return-path of the mail is not correct.

when i send a report on mail-tester.com, in the source code i see that the return path is like domain@mail-tester.com

I think that the mail i sent to orange will be dropped systematicaly if the return-path is like orange domain.

Thanks for your response.

@mattab commented on April 8th 2015 Owner

Hi @Back-Sephiroth

thanks for the report. We may have hit the same problem at Piwik PRO. it looks like there is a feature in Zend_Mail v2 http://framework.zend.com/manual/current/en/modules/zend.mail.message.html setSender that maybe we could use. Not sure if it would fix the issue but it would be worth to try it.

This bug results in several problems, for example scheduled reports not arriving at destination, and also sometimes gmail marking those emails as spam.

@mnapoli commented on April 9th 2015 Contributor

@mattab There is a method in Piwik\Mail to set the sender and it is indirectly called in scheduled reports to the noreply_email_address INI config option (default value is "noreply@{DOMAIN}").

Did you mean something else?

@mattab commented on April 9th 2015 Owner

email sent from Piwik can have two separate email headers like this:

Return-Path: <php_anonymous<a class='mention' href='https://github.com/lb'>@lb</a>-2.cloud.piwik.pro>
Received: from lb-2.cloud.piwik.pro (lb-2.cloud.piwik.pro. [])
From: "Password recovery (Piwik PRO)" <robot<a class='mention' href='https://github.com/piwik'>@piwik</a>.pro>
  • An idea that may solve the problem in this issue (and PIWIK-1934 on jira) would be that in email headers the php_anonymous<a class='mention' href='https://github.com/lb'>@lb</a>-2.cloud.piwik.pro is replaced by robot<a class='mention' href='https://github.com/piwik'>@piwik</a>.pro.
@mnapoli commented on April 13th 2015 Contributor

OK indeed Return-Path is a separate header from From I didn't know that, and indeed we only set From.

I am not sure that setSender() in ZF2 would do what we expect however there's setReturnPath() in both ZF1 and 2 (same thing).

The problem is that it might work with Smtp transport (but there's no confirmation on that) but it will not work with Sendmail (the default option). Quoting from the docs (ZF1 and ZF2):

If you set Return-Path on your mail, see Configuring sendmail transport. Unfortunately, setReturnPath($email) method does not perform this purpose.

It seems the only way to have that header set with sendmail is to either:

  • customize the CLI command in php.ini, for example:

    sendmail_path = /usr/bin/sendmail -f noreply<a class='mention' href='https://github.com/example'>@example</a>.com
  • pass the CLI option to the Sendmail transport:

    $transport = new Zend_Mail_Transport_Sendmail('-f noreply<a class='mention' href='https://github.com/example'>@example</a>.com');

    I don't know if it works if the -f option is already configured in php.ini

This is the solution for the Sendmail transport, I don't know if setReturnPath() works for Smtp (or if there's another way) as I couldn't find anybody talking about it, and the documentation mentions to use sendmail if we want to set that header so it might not be possible.

On the other hand I had a look at SwiftMailer (most used emailer in PHP) and it seems it abstracts that problem: you add the return-path header by calling setReturnPath() and the CLI option (-f ...) will be automatically set. The return-path is also set by default when you setFrom(). For the Smtp implementation I am not sure, I would need to look deeper into the code to be sure.


  • ZF2 is the same as ZF1
  • Setting the return path with sendmail needs to be a CLI option, SwiftMailer handles that automatically, we need to set it manually in ZF1 and ZF2. It can also be configured in php.ini.
  • Setting the return path with SMTP: it seems it should work with all 3 libraries but I can't confirm for sure
@mattab commented on April 13th 2015 Owner

@mnapoli interesting that Swiftmailer seems to handle this case automatically... maybe it would be worth using this library instead of ZF. Do you know if the migration from ZF mail to this library would be easy/low effort?

@mnapoli commented on April 13th 2015 Contributor

It would require a little effort as Piwik\Mail is <a class='mention' href='https://github.com/api'>@api</a> and extends Zend_Mail, which means we basically made Zend_Mail part of the Piwik API. So we would have to make sure to keep BC on the Zend_Mail methods if we remove it. I don't expect it to be too complex though, just take a little time to write all those methods.

It could also be a good opportunity to create a test mock for the transport layer, instead of using this hack resulting in this hack and this other hack.

@mattab commented on April 14th 2015 Owner

Decreasing priority as our issue at hand was fixed by admin team by changing postfix server configuration

This Issue was closed on July 22nd 2016
Powered by GitHub Issue Mirror