diff --git a/contact_attach.module b/contact_attach.module
index da5a3e1..631d76d 100644
--- a/contact_attach.module
+++ b/contact_attach.module
@@ -312,6 +312,7 @@ function _contact_attach_process_attachments($message) {
     $attachments = '';
     $body_text = '';
     $boundary_id = md5(uniqid(time()));
+    $mail_system = variable_get('mail_system', array());
 
     $message['headers']['Content-Type'] = 'multipart/mixed; boundary="' . $boundary_id . '"';
 
@@ -326,7 +327,7 @@ function _contact_attach_process_attachments($message) {
     foreach ($files as $file_object) {
       // Process the attachment.
       $attachments .= "--$boundary_id\n";
-      $attachments .= _contact_attach_add_attachment($file_object);
+      $attachments .= _contact_attach_add_attachment($file_object, $mail_system);
       $attachments .= "\n\n";
     }
 
@@ -345,16 +346,26 @@ function _contact_attach_process_attachments($message) {
  *
  * @param object $file
  *   An attachment to add to the message.
+ * @param array $mail_system
+ *   (optional) An associative array containing the contents of the persistent
+ *   variable mail_system. Defaults to array().
  *
  * @return string
  *   The processed attachment, ready for appending to the message.
  */
-function _contact_attach_add_attachment($file) {
+function _contact_attach_add_attachment($file, $mail_system = array()) {
   $attachment  = 'Content-Type: ' . $file->filemime . '; name="' . basename($file->filename) . "\"\n";
   $attachment .= "Content-Transfer-Encoding: base64\n";
-  // SMTP module pulls the file path from the filename property, so it can not
-  // be just the file name.
-  $attachment .= 'Content-Disposition: attachment; filename="' . $file->uri . "\"\n\n";
+
+  // SMTP module pulls the file path from the filename attribute in the header,
+  // so it can not contain only the file name if the SMTP module is used.
+  if (!empty($mail_system) && $mail_system['default-system'] === 'SmtpMailSystem') {
+    $attachment .= 'Content-Disposition: attachment; filename="' . $file->uri . "\"\n\n";
+  }
+  else {
+    $attachment .= 'Content-Disposition: attachment; filename="' . $file->filename . "\"\n\n";
+  }
+
   if (file_exists($file->uri)) {
     $attachment .= chunk_split(base64_encode(file_get_contents($file->uri)));
   }
