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?

Comments

Title:Undefined variableUndefined 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():

<?php
$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.

Thank you!

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

Status:Active» Needs review
StatusFileSize
new636 bytes

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

Status:Needs review» Fixed

Thanks, committed.

Status:Fixed» Closed (fixed)

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