trying to track down this problem has been a chore. basically, here is my situation:
I am using Subscriptions, I want new users to receive a message anytime a new forum post is created. I have my mail template and subscriptions set up. However, when ever I run cron, I get the message: Unable to send e-mail. Contact the site administrator if the problem persists.
Actually, the problem occurs with all emails sent from the site, including new user registrations.
I have uninstalled subsciptions, leaving Mail Editor, I still get the problem. The problem only goes away when I disable Mail Editor. I tried uninstalling, clearing cache, checking the DB that the tables for mail editor are gone (they are). I try registering a new user, no problem, mail goes through.
Once I install Mail Editor, the problem comes back. In watch dog, I get Error sending email.
Any brilliant ideas?
** Edit **
I have just tried the current dev release, same problem.
I tested the Beta2 on a separate site with minimal modules (and nothing that touches email), and I get the same error when I run cron. This time, I tested only by registering a new user. The new user never receives a welcome email or confirmation that the account is activated (both templates were set up in Mail Editor).
Again, thank you for your help.
** Edit **
Further investigation on my test install. Right now I have Mail templates activated for
- User - register_pending_approval_admin
- User - status_activated
When I register an account now, I receive the following 2 errors.
- Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in DefaultMailSystem->mail() (line 76 of ...system.mail.inc
- Unable to send e-mail. Contact the site administrator if the problem persists.
this is with Beta2 installed. So I feel like maybe system.mail.inc is not receiving the proper inputs or they aren't formatted as it expects.
Thank you so much for the help!
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | mail_edit-1488896-16.patch | 689 bytes | les lim |
Comments
Comment #0.0
scottsawyer** Edit - 2012-03-18 5:23pm EST **
Comment #1
salvisPlease install and enable the Devel module and enable its Traceback Error Handler to find out what parameters are passed to mail().
Comment #2
scottsawyerHello salvis,
I was hoping you'd catch on to my issue, I appreciate how attentive you are to the queues.
I have installed Devel, enabled backtrace, and went through the process of creating a new account where there should have been an email generated.
I am still receiving the same error "Unable to send e-mail." I am not seeing any additional information about what is being sent to mail(). Should this info be displayed on screen? I checked the log, and it seems that I get the same mail error -
Not sure why this one doesn't have a 'to' entry in the message.
Is this what you were looking for? Some how I feel like you wanted Devel to out put something on my screen, which it is not.
Further, not sure how this might help or hurt, in mail_edit_alter.inc, I uncommented lines 99, 100
I was hoping this would give me something to look at, but it doesn't show on my screen.
Thanks again for your help. Let me know how to get the info you need.
** EDIT **
I spoke too soon, I actually do get the output:
So, what this looks like is the $message['to'] is not present. I will further test and see if I can find out what happened to my "to" val.
Comment #3
salvisTry clicking on the
... (Array, 11 elements)line, it should expand dynamically (there are situations where it doesn't work though, unfortunately).Yes, you should see it on the screen. However, it's only displayed when the current user has the 'view Devel information' (or something like that) permission.
The additional info will not be displayed for the "Unable to send e-mail." message but for "Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in DefaultMailSystem->mail() (line 76 of ...system.mail.inc"
Enable all Backtrace options, to maximize the chances of at least one getting through.
The debug code that you uncommented deliberately sets
$message['to'] = '';to kill the outgoing message (while debugging). Don't forget to comment that out again. (I sure hope we're not seeing a case where someone enabled that debug helper and forgot to disable it afterwards.)Comment #4
scottsawyerHey Salvis,
Thanks so much for the continued help with this. I uncommented those lines, not to worry. I have been going through all of the array values of $message.
Here is the output of the array:
It really feels like this is being thrown by drupal_mail or something, but it's weird that things work when I don't use one of the enabled Mail Editor templates. I have not made any changes to any of the templates, btw.
Did I mention that you rock for the quick responses?
** EDIT **
I added two new dpm()'s to the function _mail_edit_mail_alter()
Directy after the opening '{'
Directly before the closing '}'
Here is my result:
The only differences I noticed is that the body[0] went from 577 chars, to 592, even though the body text is identical. Do you think there could be some trailing white space or something that may cause the mail function to choke?
Comment #5
salvisThank you — quickly-responding serious testers are very motivating! :)
Hmm, 15 characters more. We may be replacing LF with CR/LF. Do we have 15 lines in the message?
The subject gained one character, too. Now THAT is disturbing! If we added a control character at the end of the subject, that could cause subsequent mail header lines (which might include the To header) to be ignored, actually seen as part of the body.
Try saving the subject at the top in a helper variable and restoring it at the end.
On what platform/operating system are you running?
Comment #6
scottsawyerBoth of the sites are on Godaddy shared hosts. I know all the issues, but I assure you, I am sending mail just fine when this module is not envoked. I don't have any other mail modules installed on my test install, though, on the (soon to be) production install, I am using Subscriptions (great module, btw).
Ok, I've been trying a lot of different things with the subject
I created a variable $helpersubject = $message['subject']
Then, at the end, set $message['subject'] = $helpersubject
500 error.
I commented out the line
replaced with:
I still get 70 chars on the initial dpm, 71 at the end.
I tried commenting out the entire line
500 error.
I think you are exactly right about the 15 lines, in the Mail Editor template for status_activated, there are 16 lines, or 15 line returns.
SO, that could be happening to my subject.
Comment #7
salvisThat is really nasty! There's nothing we can do, really, if you can't even do simple assignments.
Maybe try
It sure would be interesting to find out what that extraneous character is...
Try something like
Comment #8
scottsawyerIf I comment out all of the lines for $message['subject']: 500 error.
It seems to me that if I commented all of the $message['subject'], it would just pass what ever the default $message['subject'] to the drupal_mail function, right?
Something I tried was setting :
Then I did:
This doesn't give 500, but it still returns 71 chars.
Working on some regex to try and remove any cr and lf. So far, not winners.
I will test the code you recommend in about 30 minutes. Family stuff.
I really appreciate you staying with me on this, I have to give my client a progress report in the morning. We are so close on this project, I just need to be able to get these subscriptions out to the members.
Comment #9
scottsawyerTested this code:
Returns 500
Tried an alternate I've been playing with
Returns
So... what it is looking like is $message['subject'] is actually an array???
Starting all the way over with my original assignment:
Returns:
Helper - Account details for ssawyer408 at ScottSawyerConsulting.NET (approved) => Account details for ssawyer408 at ScottSawyerConsulting.NET (approved)
So it looks like $message['subject'] is something like
Which isn't what I would have expected.
I will try doing all the string functions on both the $key and $val of the $message['subject'] array, then reassign.
I'll be back...
** EDIT **
Just a quick update.
It seems that if I attempt to set $message['subject'] in any way, the very last manipulation must be drupal_html_to_text($something);
Even if I attempt to set $message['subject'] = $message['subject'], or not set $message['subject'] at all, I get a 500 Internal Server Error.
I am fairly certain drupal_html_to_text is adding some lf or cr and causing the email to not send.
... Some time later...
I just tried this again, removing all references to $message['subject'], dpm, variable assignments, templates, everything.
Well, the message goes through, at least on my test site, and only on one of the built-in User templates, (on new user activation).
I am still at a loss as to why I can't seem to successfully set a $message['subject'] in _mail_edit_mail_alter(). And I am afraid that on my customer's site, where we are using Email Editor to send Subscription notifications to our users, we will wind up sending messages with no subject at all, or worse, it will not send without a subject...
I guess that will be my next comment.
I really want to thank you again for your help thus far, and hope you stick with me until we get some sort of acceptable solution.
Comment #10
scottsawyerWell, partial victory. On my customer's site, I added my modified version of mail_edit_alter.inc with all references to $message['subject'] removed, and the Subscriptions notifications get through, only no subjects are included in the emails.
So, at least we have that.
I am going to spend some more time with this, as sending email with no subject is not really acceptable.
salvis, if you have any more great ideas, I am all ears.
Comment #11
salvisAt this point I'm convinced that this is a bug in the PHP version which is installed in your Godaddy account. Just move away from Godaddy.
If your "customer's site" is on a different host, it would probably have worked from the start...
Comment #12
scottsawyerHey salvis,
You might be very well correct. Changing hosts isn't really an option at this point. As with most Drupalers, I have had my fair share of experience with Godaddy, but at the end of the day, they are one of the biggest hosting companies, their prices are really low (I know, you get what you pay for :), and I have only, on very - VERY rare occassion run into a problem that just boiled down to no solution available.
I may have mentioned that I felt like drupal_html_to_text was breaking the subject (thanks in no small part to your insights), so I had the idea to rewrite that function, and only call my new function on the $message['subject'].
So, my _mail_edit_mail_alter looks like this: (note the comments around $message['subject']
And the companion function mail_edit_html_to_text (placed in the same file mail_edit_alter.inc
Items that I changed from the original drupal_html_to_text
Magically, everything starts working on both of my sites - templates are being parsed, subscriptions are being sent, and I will meet my deadline!
Final note to anyone who is experiencing the aweful Unable to send e-mail. Contact the site administrator if the problem persists., check to see if your function is using drupal_html_to_text, you maybe picking up a line ending that could cause breakage in the drupal_mail.
And a last word to salvis, thank you thank you for your help, and keep up the great work! If you are ever in Atlanta, hit me up, I owe you a beer.
** Now to remember not to break my scripts when I update next....
Comment #13
salvisCongratulations for hacking this into shape!
Apparently, there's some ambiguity in this area: #234403: drupal_mail_send() should separate headers with CRLF
What bothers me about Godaddy is that most of your interventions resulted in crashes.
Now that we know what causes the issue, I intend to commit the following change to Mail Editor:
to
(Just add a trim() call.)
Could this work for you?
Comment #14
scottsawyerWow, that is way better than my hack! I am going with your solution. I had actually tried various preg_replace / str_replace / substr expressions and was getting nowhere.
Great job. Thanks again for all the help, never would have solved this with out it!
Comment #15
salvisYou've been pretty determined, too. Thanks for the ride!
Committed to the -dev version.
Comment #16
les limThanks to both of you for going through all of the above - I was experiencing the same problem on a Pair Networks hosted site, and the trim() resolves it.
The current dev version doesn't have trim() though - it's trying to call strip(), which is undefined.
Patch attached.
Comment #17
salvisOuch, thanks!
Committed to the -dev version, give it up to 12h to be repackaged.
Comment #19
rnochezmc commentedI have a similar issue but with a language translation installed (Spanish). When I use only English (BTW the site is also hosted at Godaddy), there is no problem but when I activate Spanish, I receive the message "Unable to send emil. Contact the site ...". I'm a newbie in Drupal. I installed Drupal in my local development computer and worked fine, I installed it in Bluehost.com and no problem but unfortunatelly my client is with Goddady and I need to make it work.
Comment #20
salvisPlease don't hijack issues to unrelated projects.
Open a new issue in the other project's queue, and if you think that this thread could help, then post a link to this thread.
Comment #20.0
salvis** Edit **
Further testing, better info, I hope.