Not until I run cron manually, I (as 'example user') don't get the emails I expect from my subscriptions after the entered period of time. I cannot find any possible reason for this in the log entries.

Once I run cron manually (e.g. on admin/reports/status), all the pending emails are sent out. In addition, I find new log entries:
one from Subscritions for each recipient, approximately: "Error when sending the notification to <user name> (<user's email address>)", although the user got the notification finally,
and one closing success message from Cron (with the same timestamp): "Subscriptions sent 0 single and 2 digest notifications in 0 of 235 available seconds; 0 queue items left.".

You know, it's quite dissatisfying to have to run cron manually every now and then...

BTW: I'm observing this problem since a couple of previous versions before beta2, only now some "fatal error" messages don't appear anymore (reported in some other issue).

CommentFileSizeAuthor
#15 error1.jpg46.78 KBS.Siva
#15 Settings2.png430.13 KBS.Siva
#15 Settings3.png323.79 KBS.Siva

Comments

salvis’s picture

Component: subscriptions_event » Miscellaneous
Category: bug » support
Status: Active » Closed (won't fix)

cron is a service that you have to set up on your website outside of Drupal. It will periodically load cron.php, according to how you set it up.

This is not only outside of Subscriptions, but outside of Drupal, but I'm sure you can find helpful information in the same place with Drupal-1st-time-installation information, or with the instructions that come with your web hosting package.

Garnerin’s picture

Status: Closed (won't fix) » Active

Sorry, I didn't mention that cron has been set up in my webserver environment (to load cron.php every minutes 5, 20, 35 and 50), and sure, I'm aware of the cron service being outside of Drupal and the way how to use it. And indeed, it runs with all of the currently activated features making use of it, e.g. sending notifications when new versions of contributed modules are available, fetching news feeds, and with others -- except with Subscriptions.

I'm taking the liberty of reopening this issue again, due to this misunderstanding. I'd be very glad if you had an idea why cron could fail in working with Subscriptions especially and in sending out the notifications.
Could there something be wrong with file access permissions on the server machine? Which files should be accessable in the Submissions directory?

salvis’s picture

If Subscriptions works in manual cron but not in real cron, then you have a weird set-up. For example something like multiple subdomains running on the same database and cron being called on the wrong subdomain.

If manual cron works, then automatic cron works as well, on a normal site.

The error messages that you reported originally are due to an error status returned by the drupal_mail() core function in _subscriptions_mail_send(). Subscriptions can't tell what's wrong with your site, it only gets a true or false back, but the problem is outside of Subscriptions.

eblues’s picture

I'm running 6.x-1.0-beta2. I don't have the problem with automatic cron. My subsription notices are being sent properly when cron runs automatically.

However, I am having the same problem regarding the error messages received in dblog after cron runs and the subsciption notices are sent. The email notifications do go out, but the "Error when sending the notification to ()" is posted for every user receiving subscription notices.

When the email function is used in other areas of my site, such as new user registration and the user contact form, there are no mail errors reported by drupal, so the error message does seem to be specifically related to the subscrption module.

Can you make any suggestions on how we can help track down the source of these error messages?

salvis’s picture

That is strange indeed. Maybe the other modules just don't check the return code of drupal_mail()...? Or your drupal_mail() doesn't like running during real cron...?

Just to be sure we talk about the same thing — this is the code (and the error message, the exact wording is a little different!):

function _subscriptions_mail_send($mailkey, $name, $to, $subject, $body, $from, $uid) {
  global $base_url;
  $url = parse_url($base_url);
  $list_id = variable_get('site_name', '') .' '. t('Subscriptions') .' <subscriptions.'. $url['host'] .'>'; 
  $mail_success = drupal_mail($mailkey, $to, $subject, $body, $from, array('List-Id' => $list_id));
  $watchdog_params = array('@name' => $name, '@to' => "<$to>");
  if ($mail_success) {
    // some lines left out
  }
  else {
    watchdog('subscriptions', t('error mailing notification for @name at @to', $watchdog_params), WATCHDOG_ERROR);
  }
}

drupal_mail() Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

Can you make any suggestions on how we can help track down the source of these error messages?

Keep adding watchdog() calls in drupal_mail() and further down to narrow down the source of the error return code.

EDIT: "api" => "drupal_mail"

eblues’s picture

I'm not php savvy so a bit out of my element here, but here goes anyhow...

I'm looking in subscriptions_mail.module, hopefully that's the correct source of the code. The code you posted looks like 5.x code, the corresponding code from the 6.x-1.0-beta2 package is below.

function _subscriptions_mail_send($mailkey, $name, $to, $subject, $body, $from, $uid) {
  global $user;

  $mail_success = drupal_mail('subscriptions_mail', $mailkey, $to, user_preferred_language($user), array(
    'account' => $user,
    'object' => NULL,
    'context' => array(
      'recipient' => $to,
      'subject' => $subject,
      'message' => $body,
    ),
  ), $from, TRUE);

  $watchdog_params = array('@name' => $name, '@to' => "<$to>");
  if (!empty($mail_success->result)) {
     // some lines left out
  }
  else {
    watchdog('subscriptions', 'error mailing notification for @name at @to', $watchdog_params, WATCHDOG_ERROR);
  }
}

The code is somewhat restructured for v6.x. The potentially significant differences I spot are:

1. $mail_success = api() in your post vs $mail_success = drupal_mail() in the packaged code. I'm guessing api() is just a holder, and that drupal_mail() is the correct code.

2. The drupal_mail(parameter list) is different between the two versions:
5.x = drupal_mail($mailkey, $to, $subject, $body, $from = NULL, $headers = array())
6.x = drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE)

You don't per chance spot anything in the 6.x code that could be amiss?

To complicate things a bit, I'm using the SMTP Authentication Support module. If Garnerin also uses this module, perhaps it's the source of the problem.

Not knowing php, I'm not able to trace the error using your suggested method, unless it wouldn't be too complicated a process and you could lead me by the hand.

Perhaps someone else who's having the problem and is php capable will step in.

salvis’s picture

Ah, sorry, yes, D6. And the code says "drupal_mail", not "api" — an editing error.

drupal_mail() has indeed changed quite a bit between D5 and D6, but the call is correct. The return value has changed, too, and there may be a problem: it works on my test system as it stands, but the code is wrong. It should be:

  if (!empty($mail_success['result'])) {

Please try that.

eblues’s picture

Salvis, that took care of it, no more error messages!

I guess this thread kinda got hijacked away from it's primary support topic regarding the problem with auto cron runs. I'm not sure of the correct procedure, but this discussion should be re-titled to include a reference to the Subscriptions error messages in watchdog (dblog) when sending email notifications so that folks having that issue can find it.

thanks,
Herm

salvis’s picture

Title: Emails not automatically sent by cron » Emails not automatically sent by cron / bogus "error mailing notification"

Good, thanks. Committed to 6.x-1.x-dev, give it up to 12 hours to be repackaged.

Hopefully this will help the original issue, too, by removing error messages if they're bogus.

Garnerin’s picture

I don't know what it was on my website which made the notifications being sent from then on, either the change from PHP4 to PHP5 or that I managed to review and correct th cron job, both happening at the same time... However now, the notifications are sent from my site also. From my point of view, you may close this issue.

salvis’s picture

Status: Active » Fixed

Good, thanks for letting us know.

stevryn’s picture

I have same behavior using Drupal 5.10 & subscriptions 5.x-2.2

salvis’s picture

Title: Emails not automatically sent by cron / bogus "error mailing notification" » BETA2: Emails not automatically sent by cron / bogus "error mailing notification"

I have same behavior using Drupal 5.10 & subscriptions 5.x-2.2

That would be a completely different problem. Open a new issue.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

S.Siva’s picture

Title: BETA2: Emails not automatically sent by cron / bogus "error mailing notification" » "error mailing notification"
Version: 6.x-1.0-beta2 » 6.x-1.1
Status: Closed (fixed) » Active
StatusFileSize
new323.79 KB
new430.13 KB
new46.78 KB

hi i am using Subscriptions 6x1.1 module, i have an issue for notification mail error. But when i tested in test server , it is sending mail, but i

followed the procedures the same in prodcution, it is throwing error. i don't know where i had done a mistake. I have enabled the cron in crontab.

Here i have attached the permission and settings what i have done. Help me to find a solution.

salvis’s picture

You're using an old version of Subscriptions. I assume this has been running for a long time.

If mail suddenly stops working, you have to investigate what has changed between when it used to work and now. It's very unlikely that this is related to Subscriptions.

S.Siva’s picture

Version: 6.x-1.1 » 6.x-1.2

Hi Salvis, i updated the subscription module . to 6.x.1.2. I followed the settings given in the documentation page. Still it is throwing error email

notification. I don't know how to fix it. I checked all the settings, i have also enabled smtp module.

salvis’s picture

I don't know smtp module. Maybe disabling it would help?

It seems that "Error sending e-mail" is not being generated by Subscriptions but by some other component. The subsequent "error mailing notification" is only a consequence of the first error.

You need to fix the first error before it makes sense to investigate the second one.

Again, look into what you changed when the error first appeared.

salvis’s picture

Issue summary: View changes
Status: Active » Closed (outdated)