Friday 1st February 2008

by Sajith M.R

When you send mail from php code, you use mail() function for this purpose. Here is another library from PEAR for sending MIME mails including html mails, attachments, inline picture attachment , plain text mail etc.

The steps to install this library is :

pear install http://download.pear.php.net/package/Mail_Mime-1.5.2.tgz
pear install Mail

(you need a pre-installed PEAR library)

From the php code you can create a function for sending mails

public function sendMail($Content,$to,$subject,$from=’no-reply@mysite.com’, $type=’html’,$attachment=false )
{
require_once (”Mail.php”);
require_once (”Mail/mime.php”);

$crlf = “\n”;
$hdrs = array(
           ‘From’ => $from,
            ‘Subject’ => $subject
            );

$mime = new Mail_mime($crlf);

if($type== ‘html’)
     $mime->setHTMLBody($Content); // html content
else
     $mime->setTXTBody($Content); // test content

//you can pass $attachment as array of file paths
if($attachment)
  foreach($attachment as $file)
      $mime->addAttachment($file, ‘image/jpeg’);

//do not ever try to call these lines in reverse order
$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$mail =& Mail::factory(’mail’);
$mail->send($to, $hdrs, $body);
}

You can use this link for another example: http://pear.php.net/manual/en/package.mail.mail-mime.example.php

For more examples go : http://pear.php.net/manual/en/package.mail.mail-mime.php

Tags: ,

· · · ◊ ◊ ◊ · · ·

4 Responses to “PEAR – MIME Mail”

  1. anil says:

    hello i am enable to connect from pear i am working in php5 on xampp.. but i am not vonnected from pear library…

    please send me code and suggest that how to connect from pear

    thax..

    anil

  2. zak says:

    or is t that you used the algorithm to separate one row sound file into a file that sounds 3d and if this is the case then man you need to sell this info to a compainy for millions

  3. zak says:

    how did you record this did you put two micraphones on a person and record the sounds from each on seprat audio divices and then syncranis the two audio chanels or did you record with the same recording divice also what mic’s did you use and where dose the algorirthm come in

  4. paul says:

    Hey Tahnks for your information…
    My problem with mime is that maybe I installed it the wrong directory. You mention that we need a pre-installed PEAR library. I installed this in my ‘File Manager’ section under Yahoo Web hosting. So, when I go to install mime, I get the follwing error:
    ERROR: Adding package pear.php.net/Mail_Mime to registry failed
    ERROR: Adding package pear.php.net/Mail_mimeDecode to registry failed
    What am I doing wrong?
    Thanks
    - Paul

· · · ◊ ◊ ◊ · · ·

Leave a Reply

وظائف 2011 تحويل العملات برامج برنامج تسريع التحميل برنامج الفلاش برنامج محول الصوتيات عربي hotel 2011 زيادة رواتب العساكر 1431