View Full Version : php email and pear
Check
2nd July 2007, 19:34
I used the perfect setup for ubuntu 6.06 and i see pear as a package being installed when you install php
Next we install PHP5:
apt-get install autoconf automake1.4 autotools-dev libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php-pear php5-ldap php5-mhash php5-mysql php5-mysqli php5-snmp php5-sqlite php5-xmlrpc php5-xsl php5-imap php5-mcrypt php5-pspell
I need to email attachments via php and was doing some searching and have found that this is what most people are using.
1a. Does it get installed with this how to? Or is this something else pear provides. aka i need to still install the mail portion of pear.
1b. If it doesnt get installed, does anyone know of a how to on how to get it working with ispconfig?
2. Is there another method that you guys recomend for this process or is pear the way to go here?
Thanks for the advice
Well either you build the functionality of sending E-Mails with attachments yourself (e.g. write an own class) or you take a pear package, which is imho much handier, especially when not thinking only about attachments but sending mails with additional plaintext beside html and stuff like this.
Which commands pear provides you can see by just running
pear help
also pear list-upgrades or pear upgrade-all is quite helpfull to be up 2 date with your pear packages, while the list-upgrade is only necessary to see what's new.
For sending mails I would use the Mail / Mime Class: http://pear.php.net/package/Mail / http://pear.php.net/package/Mail_Mime
On those sites you find information on how to install / use these packages the rest is normal coder's doing ;)
Normally this should work with ISPConfig (I mean ISPconfig's own apache+php are independent of this), but for at least the XLS Spreadsheetwriter I had to "patch" the config.lib.php of ISPConfig to add the peardirectory to the open_basedir directive when using safe mode. The additional http config field did not help here.
1a) The php-pear package is installed in the perfect setup guide. You should be able to use it out of the box in PHP scripts that are hosted on the main apache webserver (port 80).
Check
23rd April 2008, 20:02
1a) The php-pear package is installed in the perfect setup guide. You should be able to use it out of the box in PHP scripts that are hosted on the main apache webserver (port 80).
Sorry to dig this back up, but i still cant get it to work.
So now im not doing attachments, just want to use a seperate smtp server.
Heres the code:
require_once "Mail.php";
$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <myemail@yahoo.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "smtp.comcast.net";
$username = "myusername";
$password = "mypassword";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
When i run that i get:
Warning: require_once(Mail.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/web10/web/smileynotes/index.php on line 16
Fatal error: require_once() [function.require]: Failed opening required 'Mail.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/web10/web/smileynotes/index.php on line 16
Im not sure what you mean by "Main". This i dont think would be in the main since its on one of my sites managed by ispconfig.
So how do i get ispconfig to also read the pear packages?
Ben
24th April 2008, 11:04
Could you check at first, whether the Mail.php is locate in one of the mentioned include pathes or not, and if so, just for a test, when adding the absolute path in the require string, just to make sure that you are allowed to access this file, e.g. due to a open_basedir restriction...
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.