Simplenews was working fine before sending 100 emails per cron run, now it doesn't work when cron is run.

Emails can still be sent via the core contact form.

I've installed Supercron to find which cron process isn't working. Everything else works but Simplenews.

When I run cron, to send to 20 recipients, I see the following message in the log:
"Outgoing email. Message type: node
Subject: (email title)
Recipient: (one email address) Sent via Mime Mail"

My hosting provider says that there are no limits for sent emails and we aren't hitting resource limits. They also checked the MySQL tables for errors and didn't find anything.

Things I changed before this started happening:
- I added about 400 more subscribers to bring the total to 800.
- The email is different, although I don't see anything in the email out of the ordinary.

Comments

OneTwoTait’s picture

I tried again later and it sent 12 emails. There is a separate log entry for each email just like the log entry I wrote up above.

OneTwoTait’s picture

I've had the hosting people look at this and two separate freelance Drupal 'experts'. Nobody can fix it. Simplenews gives up, then is not run via cron.

We've also tried emails with only text (no images), in case that was an issue.

For us, we'll have to use something other than Simplenews.

miro_dietiker’s picture

Status: Active » Postponed (maintainer needs more info)

teite11
Sounds like things are almost fine. It must be something erratic on your side. It is working fine for us.

You need to debug the sending process then in more detail. Something that a Drupal expert should be able to.
Sorry, with the provided information we won't be able to understand the source of your specific issue nor will we be able to solve it.

Greetings

jboeger’s picture

My simplenews just stopped working too. Log entries say they are sending out out but not receiving tests or group sends.

How can I debug the sending process? Let me know and I will do it. Thanks.

miro_dietiker’s picture

Status: Postponed (maintainer needs more info) » Fixed

If drupal / php confirms the sending process, debugging is a server management task - no more drupal.
If you e.g. have root access to a server, you usually can see what happens on the system maillog (outgoing mails) with
# tail -f /var/log/mail.log
Fatal errors might be in
# tail -f /var/log/mail.error
There are many reasons possible that a mailing system stops working. You really need someone that understands your server to lookup what happens.

Note that we can't help you any further since this is completely hosting provider / server setup specific.

OneTwoTait’s picture

Status: Fixed » Active

Drupal does not confirm the sending process. The VPS hosting guys are sure it is an issue with the module. They say there are no errors in the logs and no hosting limits are being hit.

Log entries are made for the emails that are sent. However, not many emails are sent. Set to send 50 per cron run, it will send 50 the first 1 or 2 cron runs. After that it will send fewer and fewer.

miro_dietiker’s picture

Status: Active » Postponed (maintainer needs more info)

Taite11, see #3 and #5

We won't be able to help you with the provided information. Sorry.

miro_dietiker’s picture

Note that we've developed a module to do debugging of sending processes without bothering any clients:
http://drupal.org/project/maillog

Disable real sending in the module settings and enable logging.
You can now play as much as you like to reproduce any issues... including cron.

Enjoy debugging!

OneTwoTait’s picture

I disabled "Allow the e-mails to be sent." and enabled the other two options. I set the mailengine to Mime Mail, which is the only available option.

I ran cron about 10 times at 50 emails per cron run and it seemed to work. I ran on higher settings and a PHP Maximum Execution time message was recorded on admin/reports/dblog I continued to run cron until all emails were "sent".

So, it seems I couldn't find the issue in this manner. Might it catch the issue if I enable "Allow the e-mails to be sent."?

OneTwoTait’s picture

I went ahead an enabled "Allow the e-mails to be sent." and sent the newsletter again.

The first 8 batches of 50 were sent fine. Finally, on the 9th batch, it had the usual error: no closing "50 emails in ... seconds..." message in the log. Only about 30 emails were sent. The last email to be sent to was a Yahoo.cn.com email address. This is not a real email address. It should be to ...@yahoo.com.cn not ...@yahoo.cn.com.

I removed the incorrect email address from the subscription list. Then I ran cron again. It sent 1 email out only, then tried to send to the ...@yahoo.cn.com email and stalled again. That is, the ...@yahoo.cn.com was the last address recorded on maillog/log and only 1 new email was sent according to admin/reports/dblog.

Next I deleted that email address from the simplenews mail spool table via PhPMyAdmin. I ran cron again and it sent 50 emails.

So, it seems:
1) Each time it hits a "bad" email address, the cron process crashes and does not send out any further emails during that cron run.
2) http://drupal.org/project/maillog is useful for finding the "bad" email addresses.

So, seems my problem is fixed now that that one email address has been removed!

miro_dietiker’s picture

Title: Trying to Send by Cron » Mail/Send error leads to infinite loop and cron crash
Version: 6.x-1.1 » 6.x-2.x-dev
Component: Usability » Code
Category: support » bug
Priority: Normal » Critical
Status: Postponed (maintainer needs more info) » Active

Thank you for this detailled research.
I like first to fix this in 6--2 and then do a backport in 6--1...

I think if a send fails we should simply mark it as failed and continue with others. We might retry once later, but this is not so important compared to the need to finally cancel this specific address if failing.

I'm setting this even to critical since the send process is completely broken if our address check (by checking the string format only) knows less than the real send tries to do (such as a dns lookup)...

miro_dietiker’s picture

Bumping this issue also.
I's like to see this fixed before 6--2 is getting released.

Is someone working on this?

miro_dietiker’s picture

j0nathan’s picture

subscribing

miro_dietiker’s picture

Priority: Critical » Normal
Status: Active » Needs work

OK here we go.
In case of error i've fixed the infinite loop. Send errors now are set to HOLD state where no retry occurs. If you hit this case situation you need manual interaction with the database since no further action (like unsubscribe, ...) is performed.
All related data remains in the database.
Changing priority to normal.

However we need another cycle to rework the code.
It should introduce a retry cycle count in {simplenews_mail_spool} where higher cycle counts get retries with lower priorities. In addition we need a try timestamp to make sure retries happen not too early.

Spool management functions should be reworked. We should NOT load all recipients (one per line) into PHP and then add them line by line into the database. This won't scale for huge lists - see simplenews_send_node:

SELECT s.mail
FROM {simplenews_subscriptions} s
...
while ($account = db_fetch_object($result)) {
  $mails[] = array('mail' => $account->mail);
}

Also we should have an error counter for stat reasons after send complete to represent the data.

Finally we might add a send/try log as a separate table to track issue / client states / history.

jmrivero’s picture

May be some integration with another module to validate the email address will help.
I think that this happends mostly with anonimous suscribers.
Validation can be delegated to Email Verify module for example ( http://drupal.org/project/email_verify ).

miro_dietiker’s picture

jmriviero,
I support optional integration of this module.
I see that the module implementation won't correspond to everyones' wishes (additional delay in processes, source of faults, ...). Whoever don't agree with the modules' functionality won't install it ;-) so we're fine with optionally supporting it. No options needed.

Please add a separate feature request for its integration and provide a patch to add it to the module.

EDIT: the module seems pretty unmaintained and has many critical issues... so for me this is very low priority and i won't work on the integration - just add it if provided. Note that adding some check like that needs high quality as it adds lot of frustration to users. I personally prefer to have wrong adresses accepted than reject good ones...

Anyway: We MUST still improve the sending process since all addresses still have the risk of potential failure at any time - even after the best check.

jmrivero’s picture

@miro_dietiker
My point is not the integration or a new feature, thought it may be a quick way to avoid emails that pass core valid_email_address function and the concept behind email verify sounds good.
It's incredible that after all the years of use of the email, we are still trying to find a way to validate it.

miro_dietiker’s picture

Well ... we can't change the history of the net and the - sometimes - bizarre situations resulting ;-)

Pity is also that drupal core seems not to provide a way to hook / extend email address validation...

I've added the feature request item myself:
#948894: Add better email validation support

Now hurry back to work on the sending code! ;-)

Simon Georges’s picture

As #948894: Add better email validation support status is now to "needs review", should we match the status of this one accordingly, or just wait for the other one to be fixed to reflect it here ?

miro_dietiker’s picture

Simon: Better email validation support is important - but is no warranty that the mail send process works with success.
It is still possible that a previously validated mail finally fails on a mail send.
(e.g. users might delete their mailbox, even domains might disappear, ...)

However, currently the crash condition is fixed. What's remaining is reworking it a little... (see comment #15)