No automatic mails


i don’t receive the automatic statistic-mails which are scheduled both, weekly and daily.

When i click on “send email now” (german: Bericht jetzt senden), i receive it!

How is the automatic mail function triggered? I’ve read in the german forum that it’s not neccessary to set up a cronjob, isn’t it?

Can anybody help me with my problem?

Thanks & sorry for my bad english,

I was just about to ask the same. Our user can send reports manually, but the automation doesn’t work. I scanned the maillog for yesterday (Monday) and there is no noreply@piwik. So, there isn’t even a failed try. There’s also nothing in the php error log. What is supposed to trigger those mails or where could I start troubleshooting this? Thanks!

Same at me. Nothing to see in mail.log or php_error.log.

I have attempted some debugging. website triggered archiving is off here, so should trigger this. I get the following errors/output when running it. Oops, actually I get an error or a success depending on time:

Error Output:
Zend_Session is currently marked as read-only.
This error stems from just running the index.php
After the htmlified error there is another error from the Zend Framework:
Error: Action redirect not found in the controller Piwik_API_Controller.Error: Action redirect not found in the controller Piwik_API_Controller.Finished Scheduled tasks.
The command line in this case is:
<…>/index.php module=API&method=CoreAdminHome.runScheduledTasks&format=csv&convertToUnicode=0&token_auth=error page here!
Notice the missing $TOKEN_AUTH at the end.
It appears that if Zend_Session is read-only, it can’t get required data and thus fails. Which means may not run correctly from time to time!

Success Output:
No data availableFinished Scheduled tasks.
In this case the $TOKEN_AUTH is filled in.
However, it doesn’t find any scheduled tasks. As we know the superuser cannot list other user’s PDF reports. Is it really possible that this is the simple explanation for this problem? I do not want to believe that.

So I added a report for the superuser. Still no go. It still has “No data available”. Where do I find these data for further troubleshooting? Data in table piwik_pdf looks good. If that is the data it’s looking for …

“Zend_Session is currently marked as read-only” means the session files in tmp/sessions are not writeable by the web server user, or cron user, in your context.

The scheduler runs in superuser mode, so it doesn’t require the token auth.

I don’t know where the redirect is coming from.

I was running the script as root. Furthermore, I do not get this message all the time. I was getting it when I started testing, not later. So, with all respect, this explanation doesn’t look right to me.

Why is it then retrieving and using the token?

What “data” exactly is it looking up?
Also, keep in mind, that it is apparently able to archive, but cannot get data for the reports.

That’s the general explanation for the error. The error message is actually thrown from several places in Zend_Session, but without a backtrace, I can’t narrow it down for you.

Someone else from the team will have to answer re: the task scheduler and pdf reports.

Is there a way to get a backtrace? Anyway, I think the real problem is not the session read-only thing. I think that appears temporarily. The problem is that when it runs thru it thinks there is no scheduled tasks and I don’t know how to troubleshoot that :S

Ok, I accidentally found the source of the problem. Still no fix, though. I checked tmp/sessions and when walking up I found several PDF reports in tmp. I grepped the maillog for the time and found the sending attempts. The reports get sent with a reply address of noreply@unknown which is rejected because it is not an FQDN. Very well. However, the manual reports do get sent out with an FQDN. So, the question is why? The manual reports are sent with noreply@webhost-FQDN. I think the script has a problem to identify the hostname, probably it uses $_SERVER[‘HOSTNAME’] and that is bound to fail on the shell/cron. The script should be fixed to always identify a correct hostname and while I think about the “noreply” thing I think it would be best if you added a configurable option to set a sender address, preferably on a per website basis. Shall I open a bug for it?

While I’m in the tmp area I found that sessions is filled with plenty of sessions files mostly or exclusively from Jan 4/5/6/7. Shouldn’t these have been cleaned away? I did my update to 1.1.1 around that time. Is there a chance this stopped the cleaning for these files?
As I said above there’s also those PDF reports sitting in tmp. I assume they didn’t get cleaned because the send failed?

Looking at core/Mail.php, we don’t set the Reply-To. (Presumably, this is set to some default by the mailer.) Can you try adding this to the end of the setFrom() method in core/Mail.php?

parent::setReplyTo($email, $name);

Session files should be garbage collected automatically. Check the ownership/permissions allow the web server user to delete them.

Reply-To is of no interest to this. The SMTP connection is done with an envelope TO and FROM, Reply-To is just another header in the data section. I’ll have a look at Mail.php later, thanks for the pointer to it. The problem must be that you simply cannot pick up a valid hostname when not running in a webhost environment.

A few minutes later: yes, I was right. I changed

$email = str_replace('{DOMAIN}', $piwikHost, $email);


$email = str_replace('{DOMAIN}', '', $email);

and it connects with that FROM string.
As I said, if run from cron/shell it cannot pick up a hostname. $piwikhost is probably filled from $_SERVER and that is not available on the shell. You would have to pick up $_ENV[‘HOSTNAME’] or (better in my eyes) an email address that is set in options.

Hm, if(strlen($piwikHost) == 0) apparently delivers something > 0.

core/Url.php:   static public function getCurrentHost($default = 'unknown')

I’ve changed core/Mail.php (near the end) like this and expect this to be working via cron.

	public function setFrom($email, $name = null)
		$piwikHost = Piwik_Url::getCurrentHost();
		if(strlen($piwikHost) == 0)
			$piwikHost = '';
		elseif ($piwikHost == "unknown" )
			$piwikHost = $_ENV['HOSTNAME'];
		$email = str_replace('{DOMAIN}', $piwikHost, $email);
		parent::setFrom($email, $name);

This will set the machine hostname which most often is not the same as the webhost hostname. But it will suffice for now.
As I said I think the best solution is to let people configure that themselves, preferably on a per website basis, so they can set their preferred address.
Also, I recognize that it doesn’t take the PDF report title (Description). I think the title should appear either as the FROM name or in the subject.

Thanks. I’ve added a reference to your patch to ticket 1961.

Thanks. I’ve added your lines in the Mail.php. Tomorrow we will know more… :wink:

I can confirm now that it works :slight_smile:

Uhm, where/how should I report translation bugs? The German translation for “Daily” is used incorrectly in this context and looks rather weird. “Täglich” is an adverb, not an adjective and adjectives have to be declined for each single case. Also, you cannot use uppercase here (this applies to the English as well I think, it should be lowercase here). So, in this case it has to be “täglicher” and not “Täglich”. I assume there is a “Daily” where the translation “Täglich” is absolutely correct in the original context and which gets now reused everywhere, including in the middle of sentences. You can’t do this in many languages, most languages are more complex than English in this respect. You have to take the whole sentence and translate it.

Hi Bolero, and thank you for your patch.

But I don’t understand exactly how to apply it. Do I have to replace the function “getCurrentHost” with “setFrom” or add “setFrom” to the code ? On which line ?

thank you for your answer!


Nonono, I’ll edit the original post for clarification.

Nonono, I’ll edit the original post for clarification.[/quote]

;-D Ok perfectly clear now !