When I tried to use the contact form I received the following message

Warning: implode() [function.implode]: Invalid arguments passed in DefaultMailSystem->format() (line 23 of /home/french2/public_html/ebhc2014.org/modules/system/system.mail.inc).

I had the same problem when using the admin/people module when sending an account activation message to a new user

Location	http://ebhc2014.org/?q=user/160/edit&destination=admin/people
Referrer	http://ebhc2014.org/?q=user/160/edit&destination=admin/people
Message	Warning: implode() [function.implode]: Invalid arguments passed in DefaultMailSystem->format() (line 23 of /home/french2/public_html/ebhc2014.org/modules/system/system.mail.inc).

It is repeatable by switching mail logger on and off
Using Drupal 7.15

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

thirdboxcar’s picture

Same issue. I'm trying to use it with Webform, but whenever I enable Mail Logger I get the above error.

Rick G’s picture

FileSize
2.1 KB

This is because mail_logger_mail_alter changes the message body to a string, when the DefaultMailSystem class expects an array.

The attached patch fixes this issue, as well as changing the logging behavior to log only messages that are flagged to 'send' rather than simply 'build'

Rick G’s picture

FileSize
2.14 KB

I saw another solution to this problem in issue 1622878 that uses the mail system to format the message body.

The attached patch incorporates elements from my patch above and the patch from the other issue.

deetergp’s picture

I get a very similar error when I have mail_logger installed on a fresh (or otherwise) install of Drupal 7.16. I install Drupal, install mail_logger and enable it, then switch to an incognito browser window and create a new account. Once account creation redirects me to the "Thank you for registering for an account." message it also includes two of the following warnings:

Warning: implode() [function.implode]: Invalid arguments passed in DefaultMailSystem->format() (line 23 of /Users/XXXXXX/Projects/education/drupal-7/public_html/modules/system/system.mail.inc).

The account gets created and an email gets sent, but the email has no body text at all. Interestingly enough, the outgoing body text does get logged in mail_logger, it just doesn't get passed on to the outgoing email. It was this behavior that initially caught my attention, I noticed it before taking note of the warning message. (In fact, I am not entirely certain I got the warning the first time I noticed the lack of body text)

I tried the above patch thinking it would at least get rid of the warnings I was getting when I went to create a new account, but it did not.

Edit: I did a git apply -stat rather than git apply which ran successfully but did not actually apply the patch. When I tried to just git apply the patch, it errored out with error: sites/all/modules/mail_logger/mail_logger.new.module: No such file or directory.

deetergp’s picture

Status: Needs review » Active
FileSize
41.36 KB

Since I had difficulty applying the (2nd) patch, I took the code Rick G wrote and applied by hand to a fresh install of mail_logger in a fresh Drupal 7 install and found that it did indeed get rid of the warning message and put the body content back into outgoing emails. I rolled it into a new patch, which I tested locally and had no issues applying. I think it is ready for someone else to have a look at it and hopefully have it rolled back into the mail_logger codebase.

Edit: Ignore this patch, see the next comment for the one to use.

deetergp’s picture

Status: Active » Needs review
FileSize
2.76 KB

Okay. My apologies, I am kinda figuring this patch stuff out myself.

Please ignore my previous patch, it was diffed against a master branch that did not have mail_logger installed, so the patch contained all the mail_logger files. This new patch is smaller and contains nothing but just the changes to mail_logger.module. I have tested it against a clean clone of the mail_logger repo and a clean install of Drupal 7.16. The new patch is ready to be tested.

tlattimore’s picture

Status: Active » Reviewed & tested by the community

I have functionally tested the patch from #6 and can confirm that it resolves the issue reported here. RTBC.

deetergp’s picture

Status: Reviewed & tested by the community » Fixed

This patch has been rolled back into 7.x-1.x-dev. I have installed mail_logger using drush dl mail_logger and pulled it down as a part of the Guardr distro and verified that it worked in both instances. I am calling this one fixed.

Status: Fixed » Closed (fixed)

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