Revision: 1654
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1654&view=rev
Author:   cimorrison
Date:     2010-11-29 08:36:08 +0000 (Mon, 29 Nov 2010)

Log Message:
-----------
Converted sendMail() to use Mail_Mime

Modified Paths:
--------------
    mrbs/branches/ics_attachments/web/functions_mail.inc

Modified: mrbs/branches/ics_attachments/web/functions_mail.inc
===================================================================
--- mrbs/branches/ics_attachments/web/functions_mail.inc        2010-11-29 
08:31:08 UTC (rev 1653)
+++ mrbs/branches/ics_attachments/web/functions_mail.inc        2010-11-29 
08:36:08 UTC (rev 1654)
@@ -977,10 +977,11 @@
  * @param string  $password         smtp server password
  * @return bool                     TRUE or PEAR error object if fails
  */
-function sendMail($recipients, $subject, $body, 
+function sendMail($recipients, $subject, $text,
                   $charset = 'us-ascii', $from, $cc = NULL, $bcc = NULL)
 {
   require_once "Mail.php";
+  require_once "Mail/mime.php";
   
   global $mail_settings, $sendmail_settings, $smtp_settings;
   
@@ -1009,21 +1010,8 @@
   $username = $smtp_settings['username'];
   $password = $smtp_settings['password'];
   
+  // Parameters part
   $params = array();  // to avoid an undefined variable message
-
-  // Headers part
-  $headers['From']         = $from;
-  if ( $backend != 'mail' )
-  {
-    $headers['To']           = $recipients;
-  }
-  (NULL != $cc) ? $headers['Cc'] = $cc : '';
-  (NULL != $bcc) ? $headers['Bcc'] = $bcc : '';
-  $headers['Subject']      = $subject;
-  $headers['MIME-Version'] = '1.0';
-  $headers['Content-Type'] = 'text/plain; charset=' . $charset;
-
-  // Parameters part
   if ( $backend == 'sendmail' )
   {
     $params['sendmail_path'] = $sendmail_path;
@@ -1037,10 +1025,34 @@
     $params['username']      = $username;
     $params['password']      = $password;
   }
+  
+  // Headers part (extra headers - the standard headers will already be there)
+  $headers = array();
+  $headers['From'] = $from;
+  if ($backend != 'mail')
+  {
+    $headers['To'] = $recipients;
+  }
+  (NULL != $cc) ? $headers['Cc'] = $cc : '';
+  (NULL != $bcc) ? $headers['Bcc'] = $bcc : '';
+  $headers['Subject'] = $subject;
+  
+  // Parameters for the get()
+  $get_params = array();
+  $get_params['text_encoding'] = 'quoted-printable';
+  $get_params['text_charset'] = $charset;
+  
+  // Build the mime object
+  $mime = new Mail_mime("\n");
+  $mime->setTXTBody($text);
+  
+  // get() must be called before headers()
+  $body = $mime->get($get_params);
+  $hdrs = $mime->headers($headers);
 
   // Call to the PEAR::Mail class
   $mail_object =& Mail::factory($backend, $params);
-  $result = $mail_object->send($recipients, $headers, $body);
+  $result = $mail_object->send($recipients, $hdrs, $body);
 
   if (is_object($result))
   {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to