Notice: Undefined variable: filetype in SmtpMailSystem->mail() (line 413 of /home . . .

I get this error when I attach a file and send. The file does send though. Is this a bug in this module?

Members fund testing for the Drupal project. Drupal Association Learn more


Tor Arne Thune’s picture

Title: Undefined variable » Undefined variable $filetype. Wrong variable name used in SmtpMailSystem::mail(). Should be $file_type
Project: Contact Attach » SMTP Authentication Support

This is a bug in the SMTP module.
From SmtpMailSystem::mail():

$file_path     = $this->_get_substring($body_part, 'filename=', '"', '"');
$file_name     = $this->_get_substring($body_part, ' name=', '"', '"');
$file_encoding = $this->_get_substring($body_part, 'Content-Transfer-Encoding', ' ', "\n");
$file_type     = $this->_get_substring($body_part, 'Content-Type', ' ', ';');

if (file_exists($file_path)) {
  if (!$mailer->AddAttachment($file_path, $file_name, $file_encoding, $filetype)) {
    drupal_set_message(t('Attahment could not be found or accessed.'));

As you can see, $mailer->AddAttachment() is given a non-existing variable ($filetype) as an argument. It should be $file_type, as this variable is defined above. Moving to the SMTP module issue queue.

royerd’s picture

Thank you!

royerd’s picture

Yes, indeed. That fixes it. If that variable $filetype is changed to $file_type in on line 413, the error goes away. Good catch. Perhaps this can be changed for the next dev version?

Tor Arne Thune’s picture

Status: Active » Needs review
636 bytes

Here's a patch against 7.x-1.x for the committer.

wundo’s picture

Status: Needs review » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)

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