On Tue, Apr 20, 2010 at 2:10 AM, David McGlone <da...@dmcentral.net> wrote:
> On Mon, 2010-04-19 at 08:25 -0400, Alice Wei wrote:
>> I have not changed any of my SMTP settings since my new installation of
>> PHP with Pear. So, I am not sure what the settings are supposed to be.
>> Would I need to install anything else even when the Pear Mail package
>> has been installed?

You might, depending on if you need to use the Mail_Mime or Mail_Queue
packages also (for sending emails with attachments etc etc or for
sending mails in bulk).
 Also there's some rather nice new functionality in the more recent
versions of Mail and Net_SMTP that enable you to log the ESMTP Id of
mails you have submitted to a mail server (along with the SMTP
greeting sent by that server when you connect to it).

> Alice, I never use the PEAR install from my distro, I always download
> and install PEAR into my working folder. The benefit of doing it this
> way is so that when you move your project to a different server, nothing
> will break and you don't have to change anything.
> Sometimes when I create a new project, I'll just copy the PEAR folder
> from an older project to the new one. The only thing you may have to
> change in your PHP code is the path to the PEAR libs only if you don't
> put them in the same place every time.

When some bug is fixed or dependencies of some of those PEAR packages
change I think you'll find your attitude towards that will change -
there's a pear installer so you don't have to update and track the
dependencies by hand - you do regularly update your packages don't
you? It's smart to do so because at the very least you don't have to
implement work-arounds for bugs that have been fixed in later versions
of those packages - and in the worst-case scenario it means you're not
using versions that have PEAR Security Advisories issued against them.

I believe it's possible to have seperate pear config files per project
so you're not limited to having to use the same versions of packages
across all projects.

If you're using more than a handful of PEAR packages in your project
you might want to write your own meta-package for the project; that
way you don't have to install all those packages individually;
you just do something like "$pear install myProject.xml" and the pear
installer will download and install whichever pear packages you have
described in your xml file.

Details on doing this are at

For the record, this is the example script that I submitted to
for demonstrating how to use the PEAR packages for sending a mail with
a file attached.:

require_once "Mail.php";
require_once "Mail/mime.php";

$from = "Fred Flintstone <fli...@example.com>“;
$to = “Barney Rubble <barn...@example.net>“;
$subject = “Mail Subject”;
$message = “this is the text of the mail, sent using PEAR’s Mail packages.”;
$host = “smtp.example.com”;
$port = “25″;
$headers = array (‘From’ => $from, ‘To’ => $to, ‘Subject’ => $subject);
$smtp = Mail::factory(’smtp’, array (‘host’ => $host, ‘port’ => $port));
$mime = new Mail_mime();
$mime->addAttachment(“/home/ken/logo.png”, ‘image/png’);
$body = $mime->get();
$mail = $smtp->send($to, $mime->headers($headers), $body);

if (PEAR::isError($mail)) {
echo($mail->getMessage() . “!\n”);
} else {
echo(“Message successfully sent to $to!\n”);
echo “Queued As (ESMTP Id): “, $smtp->queued_as, “\n”;
echo “Greeting From Mailserver: “, $smtp->greeting, “\n”;


> Blessings,
> David M.
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to