Error - Bad parameters to mail() funtion, mail not sent
steve22 - March 1, 2009 - 13:31
| Project: | Mime Mail |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
I upgraded mimemail to latest dev version. Now, I have following error whenever I tried to send simplenews newsletter. Please help!
mail() [<a href='function.mail'>function.mail</a>]: Bad parameters to mail() function, mail not sent. in /home/content/n/e/p/nepfor/html/sites/all/modules/mimemail/mimemail.module on line 331.

#1
What version of simplenews?
#2
Parameter-Problem too ! Mail not sent !
Drupal 6.9
Simplenews 6.x-1.0-rc5
Mime Mail 6.x-1.x-dev (2009-Feb-22)
preg_match() expects parameter 2 to be string, array given in /web/1/000/015/530/15195/htdocs/emmy-eltern-neu/includes/bootstrap.inc in Zeile 761
#3
I am also experiencing this issue. As a possible clue to the cause, I am hosted on godaddy, which may be a commonality between those of us experiencing this bug.
#4
It's a possibility. Although I don't believe anything has changed that would account for a problem there. It would be helpful to know the version of PHP you're on.
Also, if you can add a couple of print_r() statements to aid with debugging, I'd be interested to know what you're getting passed for each of the mail() parameters from Simplenews.
Jer
#5
I removed mimemail module and upgraded to latest simplenews, the error went away.
#6
By removing mimemail, you force simplenews to use the drupal_mail functions, which are not capable of HTML based emails.
The contents of the $message variable on line 1641 in simplenews.module appear to be valid...except that the "from" and reply-to fields are non-email address in nature. Don't know if that can cause any problems.
#7
preg_match() expects parameter 2 to be string, array given in /WWWPATH/www/newsite.republicanproject.org/includes/bootstrap.inc on line 771. (within drupal_validate_utf8)
Found in Drupal 6.10 with Simplenews 6.x-1.0-rc6 and SMTP 6.x-1.0-beta3. Does not occur with mimemail removed but does occur without SMTP, so I'm pretty sure it's a mimemail issue. Tried to get print_r output, but it gets washed away in the spam, sorry.
#8
I've uninstalled mimemail, cleared caches and still get the error, is there something the uninstall misses that has to be deleted manually?
#9
What do I have to do with these "print_r()" statements ?
Where to do it ?
I'm very interested in getting this fixed - so please tell me what to do.
#10
The problem is in the subject. In mimemail.module line number 329:
foreach ($message['address'] as $a) {
$status = mail(
$a,
-----> $message['subject'], <-------------PROBLEM IS HERE----------------
$message['body'],
mimemail_rfc_headers($message['headers'])
) && $status;
If you replace this line with 'test test test', the email will be sent.
Did a print_r on this line and got the encoded line:
=?UTF-8?B?W0F3ZW5kYXcgR3JlZW4gTmV3c2xldHRlcl0gQUcgTmV3c2xldHRlciBOb3cgT24=?= =?UTF-8?B?bGluZQo=?=
Which, when entered into the subject line of gmail, does correctly display upon receipt as:
[Awendaw Green Newsletter] AG Newsletter Now On line
(notice the space between 'On' and 'line' - this space should NOT be there...also notice that there are TWO UTF-8 encoded sections in the print_r output)
Why this is rejected by the mail() function is the question.
#11
The problem is that the subject is too long. When the subject line gets too long, the UTF-8 encoded message gets split into two parts as you can see in the print_r example.
If you shorten your newsletter name and the subject line for the message, the error goes away.
I'm not sure if this can be fixed in mimemail, but that's the problem!
#12
oops replied to wring issue ;)
[deleted]
#13
I had the same problem and found the problem with drupal_html_to_text. See issue "#438058: drupal_html_to_text inserts LF in subject causing outgoing e-mail to fail" for description and patch.
#14
Had the same issue with Simplenews with mimemail. Just updated to the latest mimemail DRUPAL--6-1 and it seems to have resolved the issue.
Here's some text so people can find the error easier from google.
warning: preg_match() expects parameter 2 to be string, array given ... /bootstrap.inc on line 771.
drupal_validate_utf8
#15
Same problem whenever I use more than one word in the title of my newsletter (English).
#16
For sending mails through contact forms, for me the patch in #84883: Bad parameters to mail() (comment #77) resolved the issue. See my versions in #81