Jump to content

mail() how to


sooty2006

Recommended Posts

hi i have used the mail(); function in the past and currently it has not been sending out any emailsnow i dont know much about the php.ini could that have something to do with why its not sending the emailsi have visited the php.net site but i do everything they say!is there a way i can check to see if the server at the other end has recieved my email?thanks!

Link to comment
Share on other sites

Look back a few topics and you'll see I had a similar problem. The link I was given for using PEAR was quite useful, and worked perfectly. I'd give you a direct link but I'm on my Palm.

Link to comment
Share on other sites

ok i have downloaded the mail package from PEARit has one file called "Mail-1.2.0b1"i have included it in my php.ini and installed it on my serverand it does not work i changed the file extension to .php and it then shows another error>Parse error: syntax error, unexpected T_STRING in /var/www/vhosts/mysite.co.uk/httpdocs/Mail.php on line 1should the folder i downloaded have just one script in?

Link to comment
Share on other sites

Did you follow the installation instructions? You shouldn't have to rename anything, I doubt the Pear package includes a single PHP file. The file is probably the actual package, not a single script file. There are pretty specific installation instructions to install pear though, eventually you end up using the go-pear file to download and install additional packages. This isn't something that you just download and include. There's an installation guide here:http://articles.techrepublic.com.com/5100-...11-5163311.html

Link to comment
Share on other sites

ok thanks justsomeguy!i have read about PEAR and have downloaded the package its now on my server has installed the folders but no files because it brings up this error message before it can finish!Warning: putenv(): Safe Mode warning: Cannot set environment variable 'TMPDIR' - it's not in the allowed list in /var/www/vhosts/example.com/httpdocs/install/go-pear.php on line 1264i have folled the installation documents etc...what could be causing it i have looked at line 1264 and theres nothing wrong with it!

Link to comment
Share on other sites

The error message says that it can't create an environment variable called TMPDIR because it's not in the allowed list of variables to create when safe mode is enabled, and you have safe mode enabled. Either disable safe mode or add that environment variable to the list of allowed env vars.

Link to comment
Share on other sites

ok thanks i have done now i have installed pear on my server now i know i have to include a file for pear to work what file would i include for the mail package?

Link to comment
Share on other sites

I believe the files are already included. Check the Pear documentation to find out what the mail class is called, and you can use the class_exists function to find out if a class is defined. If it's defined then you don't need to do anything else in order to use it.

Link to comment
Share on other sites

ok ill refrase what i have just said i logged in to SSH and searched for pear folder or files i did find them they where alreeady installed on my server just not where i expected the files to be!now i have found a sample script that works but it brings up an error!Warning: main(Mail.php): failed to open stream: No such file or directory in /var/www/vhosts/testting.co.uk/httpdocs/i/page/don/test2.php on line 2Fatal error: main(): Failed opening required 'Mail.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/vhosts/testting.co.uk/httpdocs/i/page/don/test2.php on line 2does that mean that i need to include pear to the php.ini if so how?

Link to comment
Share on other sites

That's what I was saying, I believe that the installation routine of Pear does all of the integration you need. I don't think there's anything to include in your scripts. You just check if the class you want to use exists, create an instance of it, and off you go.

Link to comment
Share on other sites

That's what I was saying, I believe that the installation routine of Pear does all of the integration you need. I don't think there's anything to include in your scripts. You just check if the class you want to use exists, create an instance of it, and off you go.
haha ok im not being funny but how do i do that?i got the script off a friend it works but its just showing that error!
Link to comment
Share on other sites

The Pear documentation does seem to indicate an include file. It looks like your include path includes a pear directory. If it can't find Mail.php in that directory, try including 'mail/Mail.php', maybe it's in a subdirectory. Or ask your host how to include the pear mail package. All I can do without looking at your server is guess what it might be. If you have root access to your server then go to the /usr/share/pear directory and look around for the mail file.

Link to comment
Share on other sites

ok i tryied it and it dont work now i have just noticed that the pear directorie is not in usr/share/pearit is usr/share/psa-horde/pearso how would i change it to get the correct directorywould i need to change it on the php.ini file?

Link to comment
Share on other sites

what does this actually meanthat its saying that the include path isint therewhich it isnt there or thats where it should bei have been on php.ini and there is no include path for that directory just for other directoriesi just dont what to completely mess my server up Fatal error: main(): Failed opening required 'Mail.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/vhosts/testting.co.uk/httpdocs/i/page/don/test2.php on line 2this is my includes line right now!

include_path="/opt/psa/admin/plib:/opt/psa/admin/javascripts:/opt/psa/admin/plib/locales:/opt/psa/admin/auto_prepend:/opt/psa/admin/htdocs/domains/databases/phpMyAdmin:/opt/psa/admin/htdocs/domains/databases/phpPgAdmin"

Link to comment
Share on other sites

i have tryied all i know i think and cannot get it to work!

<?phprequire_once "Mail.php";$from = "Sandra Sender <[email="sender@orange.com"]sender@orange.com[/email]>";$to = "Ramona Recipient <test[email="test@hotmail.co.uk"]@hotmail.co.uk[/email]>";$subject = "Hi!";$body = "Hi,\n\nHow are you?";$host = "webmail.server.co.uk";$username = "[email="admin@server.co.uk"]admin@server.co.uk[/email]";$password = "paswrd";$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>"); }?>

but its still not including the pear directory! :)

Link to comment
Share on other sites

this is my includes line right now!include_path="/opt/psa/admin/plib:/opt/psa/admin/javascripts:/opt/psa/admin/plib/locales:/opt/psa/admin/auto_prepend:/opt/psa/admin/htdocs/domains/databases/phpMyAdmin:/opt/psa/admin/htdocs/domains/databases/phpPgAdmin"
If all of those are in the include path but the error is showing this:include_path='.:/usr/share/php:/usr/share/pear'it sounds like it isn't reading the php.ini that you're editing. Make a script that shows the phpinfo page and up near the top it will tell you which version of php.ini it is using, make sure you're editing that version. You might have to reload Apache in order to have it pick up the changes to php.ini, I'm not sure if there's a way to get Apache to read it immediately.
Link to comment
Share on other sites

ok what would i need to type in my SSH connection to reload apachei have checked phpinfo() and it wasnt the right php.ini script i was editing i have put the include_path in the php.ini in the correct location and still hasnt found it the directory this is wat gets me though in the correct php.ini there is no include_path its set as a comment; include_path=".:/usr/share/php"the correct location is: include_path='.:/usr/share/php4:/usr/share/psa-horde/pear'but how is it saying there is no such directory as include_path='.:/usr/share/php:/usr/share/pear'??

Link to comment
Share on other sites

The include path could also be set up in one of Apache's config files, Apache can define PHP settings also. So it's probably set up there. I don't know how to reload Apache, I'm sure the documentation is out there though. You can also set the include path yourself in a PHP file, but you would have to do that in every PHP file you want to use this in.

Link to comment
Share on other sites

ok thanks justsome guy im just trying to find out if i can reload apache2i have got to the problem and sorted it but when i change anything in the php.inithe phpinfo(); dosnot change everything stays the same so i think the problem here is i need to reload apache2 which seems stupid to have to do everytime u need to change the php.inirebooting the server does not work!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...