Hi, I love the mail module! When I use it, it does send the mail, but then it loads a page with the following error:

warning: Invalid argument supplied for foreach() in /modules/mail/mail.module on line 295.

[the above line is repeated 7 times, then continues with the following ...]

warning: Cannot modify header information - headers already sent by (output started at /includes/common.inc:320) in /includes/bootstrap.inc on line 701.

Help? Thanks!

Comments

magnestyuk’s picture

hi!

i'm also getting this error:

warning: Invalid argument supplied for foreach() in /var/www/html/modules/mail/mail.module on line 295.

warning: Cannot modify header information - headers already sent by (output started at /var/www/html/includes/common.inc:384) in /var/www/html/includes/common.inc on line 192.

is anyone else having this problem?

thanks.

gollyg’s picture

I got the same problem. Seems to be cause by the following code on line 295 of mail module:


    foreach ($mail->files as $file) {
      $email->Attachment($file->filepath, $file->filename);
    }

Seems to be fixed by checking for the existence of attachments before looping throught the array


  if($mail->files) {
    foreach ($mail->files as $file) {
      $email->Attachment($file->filepath, $file->filename);
    }
  }

Don't know what the correct process for reporting it is.

nedjo’s picture

Status: Active » Fixed

Don't know what the correct process for reporting it is.

You're doing just fine! Thanks, fix applied. (Alternately, you can generate patches--this is expected for fixes to the Drupal core, and is easier to deal with when the changes are large. But for small fixes like this, I'm personally just as happy with a post of revised code like you did.)

Anonymous’s picture

Status: Fixed » Closed (fixed)