/[drupal]/contributions/modules/smtp/smtp.module
ViewVC logotype

Diff of /contributions/modules/smtp/smtp.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.17.2.9, Tue Nov 10 01:34:07 2009 UTC revision 1.17.2.10, Tue Nov 10 11:06:14 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: smtp.module,v 1.17.2.8 2008/09/23 22:03:01 oadaeh Exp $  // $Id: smtp.module,v 1.17.2.9 2009/11/10 01:34:07 franz Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 362  function drupal_mail_wrapper($message) { Line 362  function drupal_mail_wrapper($message) {
362          break;          break;
363    
364        case 'content-type':        case 'content-type':
365          if (strpos(drupal_strtolower($value), 'text/plain') !== FALSE) {          // Parse several values on the Content-type header, storing them in an array like
366            // The message includes only a plain text part.          // key=value -> $vars['key']='value'
367            $mail->IsHTML(FALSE);          $vars = explode('; ', $value);
368            foreach ($vars as $i => $var) {
369            // Set the charset based on the provided value, if there is one.            if ($cut = strpos($var, '=')) {
370            $charset = _smtp_get_substring($value, 'charset', '=', ';');              $new_var = drupal_strtolower(substr($var, $cut + 1));
371            if ($charset) {              $new_key = substr($var, 0, $cut);
372              $mail->CharSet = $charset;              unset($vars[$i]);
373            }              $vars[$new_key] = $new_var;
374              }
375            }
376    
377            // Set the charset based on the provided value, if there is one.
378            $charset = $vars['charset'];
379            if ($charset) {
380              $mail->CharSet = $charset;
381            }
382            switch ($vars[0]) {
383              case 'text/plain':
384                // The message includes only a plain text part.
385                $mail->IsHTML(FALSE);
386                $content_type = 'text/plain';
387                break;
388              case 'text/html':
389                // The message includes only an HTML part.
390                $mail->IsHTML(TRUE);
391                $content_type = 'text/html';
392              break;
393              case 'multipart/related':
394                // The message includes an HTML part w/inline attachments.
395                $mail->ContentType = $content_type = 'multipart/related';
396              break;
397              case 'multipart/alternative':
398                // The message includes both a plain text and an HTML part.
399                $mail->ContentType = $content_type = 'multipart/alternative';
400    
401                // Get the boundary ID from the Content-Type header.
402                $boundary = _smtp_get_substring($value, 'boundary', '"', '"');
403              break;
404              case 'multipart/mixed':
405                // The message includes one or more attachments.
406                $mail->ContentType = $content_type = 'multipart/mixed';
407    
408                // Get the boundary ID from the Content-Type header.
409                $boundary = _smtp_get_substring($value, 'boundary', '"', '"');
410              break;
411              default:
412                // Everything else is unsuppored by PHPMailer.
413                drupal_set_message(t('The Content-Type of your message is not supported by PHPMailer and will be sent as text/plain instead.'), 'error');
414                watchdog('smtp', 'The Content-Type of your message is not supported by PHPMailer and will be sent as text/plain instead.', array(), WATCHDOG_ERROR);
415    
416            $content_type = 'text/plain';              // Force the Content-Type to be text/plain.
417          }              $mail->IsHTML(FALSE);
418          elseif (strpos(drupal_strtolower($value), 'text/html') !== FALSE) {              $content_type = 'text/plain';
419            // The message includes only an HTML part.          }
           $mail->IsHTML(TRUE);  
           $content_type = 'text/html';  
         }  
         elseif (strpos(drupal_strtolower($value), 'multipart/related') !== FALSE) {  
           // The message includes an HTML part w/inline attachments.  
           $mail->ContentType = $content_type = 'multipart/related';  
         }  
         elseif (strpos(drupal_strtolower($value), 'multipart/alternative') !== FALSE) {  
           // The message includes both a plain text and an HTML part.  
           $mail->ContentType = $content_type = 'multipart/alternative';  
   
           // Get the boundary ID from the Content-Type header.  
           $boundary = _smtp_get_substring($value, 'boundary', '"', '"');  
         }  
         elseif (strpos(drupal_strtolower($value), 'multipart/mixed') !== FALSE) {  
           // The message includes one or more attachments.  
           $mail->ContentType = $content_type = 'multipart/mixed';  
   
           // Get the boundary ID from the Content-Type header.  
           $boundary = _smtp_get_substring($value, 'boundary', '"', '"');  
         }  
         else {  
           // Everything else is unsuppored by PHPMailer.  
           drupal_set_message(t('The Content-Type of your message is not supported by PHPMailer and will be sent as text/plain instead.'), 'error');  
           watchdog('smtp', 'The Content-Type of your message is not supported by PHPMailer and will be sent as text/plain instead.', array(), WATCHDOG_ERROR);  
   
           // Force the Content-Type to be text/plain.  
           $mail->IsHTML(FALSE);  
           $content_type = 'text/plain';  
         }  
420          break;          break;
421    
422        case 'reply-to':        case 'reply-to':

Legend:
Removed from v.1.17.2.9  
changed lines
  Added in v.1.17.2.10

  ViewVC Help
Powered by ViewVC 1.1.2