Re: Re: Mail_Mime

From: Date: Tue, 22 Jul 2003 14:23:12 +0000
Subject: Re: Re: Mail_Mime
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-6723@lists.php.net to get a copy of this message
Ok, I was a bit confused by a couple of things of yours, but that's ok, we'll work around that. Let me show you the code I use on my web site to send myself MIME encoded e-mail, maybe that will help you. It took me awhile to get this thing to work correctly. The function below I call every time I want to send an e-mail. I use this both for sending myself web stats that a cron tab takes care of for me every night, my contact form on my web site, and also when I make updates to my site via my CMS it sends me a copy of the updates. Part of the problem I've noticed is that some Mail client act really goofy with different formatting, and the minute you tap into web mail clients things get even goofier. What mail client are you using? function sendNow($from,$subject,$message) { $message = ereg_replace('\\\\\"', '"', $message); $message = ereg_replace("\\\\\'", "'", $message); $subject = ereg_replace("\\\\\'", "'", $subject); $subject = ereg_replace('\\\\\"', '"', $subject); $text = strip_tags($message); $crlf = "\r\n";
	$hdrs = array('From'    => $from,
	              'Subject' => $subject,);
$mime = new Mail_mime($crlf); $mime->setTXTBody($text); $mime->setHTMLBody($message); $param["html_encoding"] = "7bit"; $body = $mime->get($param); $hdrs = $mime->headers($hdrs); $mail =& Mail::factory('mail'); $mail->send("insyder@insyderhomielc.com", $hdrs, $body); $returnMessage = ' <br /> <div align="center" style="font-family: tahoma, arial, sans-serif; font-size: 10pt;"> <strong>Your message has been sent!</strong> </div> '; return $returnMessage; } Tony Thomas wrote:
Thanks Stan, That didn't work either. Perhaps I should post the code. if ($file) {
               include('Mail.php');
        include('Mail/mime.php');
               $crlf ="\r\n";
               $text = $body . $crlf . $crlf;
        $html = $body . $crlf . $crlf;
                   $hdrs = array('From' => 'someone@example.com', 'Subject' => "$subject");
            $mime = new Mail_mime($crlf);
            $mime -> setTXTBody($text);
               $mime -> setHTMLBody($html);
               $mime -> addAttachment($file_path, 'application/octet_stream');
               $param["html_encoding"] = "7bit"; // at Stan's suggestion
               $body =$mime -> get($param);
               $hdrs =$mime -> headers($hdrs);
        $mail =& Mail :: factory('mail');
    }
           for ($x=0; $x < $count; $x++) {
           /* The e-mail addresses are stored in an array that is sent from an HTML form.
    The user checks boxes to indicate who should receive the message.
    The line below loops through that array and sends the messages out, one at a time. */
         $mail -> send($array[$x] ,$hdrs ,$body);
           }
} I have to apologize a bit because I'm a novice. This is my first attempt at using one of the PEAR packages. It's been trial and error. I'm surprised I've gotten this far. Any help would be appreciated. On Tuesday, July 22, 2003, at 09:03 AM, Stan Lemon wrote:
When you use the get() function try adding a param with 7 bit, like this: $param["html_encoding"] = "7bit"; $body = $mime->get($param); Until I did that I was unable to view the body of the message myself as well. Hope that helps, - Stan Tony Thomas wrote:
Hi Everyone, I'm trying to use Mail_Mime to send out e-mails with attachments. I've almost got it working, except that for some reason only the attachment shows up. The text doesn't. Here's a sample of an e-mail that I sent. The headers all appear correct, so I can't figure out why the text is not visible. This may seem slightly off-topic, but I'm hoping that those of you with more experience can 1.) find the problem with the headers, and 2.) help my figure out what I need to change to fix the problem. I'm somewhat inexperienced in both areas. I apologize if I'm leaving out pertinent information. Below is the message with headers: From someone@example.com Mon Jul 21 23:13:54 2003 Return-Path: < someone@example.com > Delivered-To: someone@example.com Received: (qmail 12441 invoked from network); 22 Jul 2003 04:13:53 -0000 Received: from unknown (HELO ninkas.nosdns.com) (207.44.246.49) by hosting-132-6.phpwebhosting.com with SMTP; 22 Jul 2003 04:13:53 -0000 Received: from nobody by ninkas.nosdns.com with local (Exim 4.20)
    id 19eoWz-0006mn-4U
    for tony@truetone.org; Mon, 21 Jul 2003 23:13:41 -0500
To: tony@truetone.org Subject: OK MIME-Version: 1.0 From: someone@example.com Content-Type: multipart/mixed;
    boundary="=_def3a261a028480ec078b84de299f6f6"
Message-Id: <E19eoWz-0006mn-4U@ninkas.nosdns.com> Date: Mon, 21 Jul 2003 23:13:41 -0500 --=_def3a261a028480ec078b84de299f6f6 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Hello world. --=_def3a261a028480ec078b84de299f6f6 Content-Type: application/octet_stream Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="file.pdf" [base64 encoding here] --=_def3a261a028480ec078b84de299f6f6--
-- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.pear.general (#6723) next »