Hi webface,
If you ran the go-pear.bat file and installed PEAR, and then installed the Mail package with all its dependencies, you should now have the required files in your system, especially:
c:\wamp\bin\php\php5.2.5\PEAR\Mail.php
If you cannot find that file but you have PEAR installed, you can just run the following command to install the Mail package:
pear install --alldeps mail
Mail.php is the file where the Mail class and the factory function reside - remember Mail::factory(). You need to add the PEAR folder to the include_path in the php.ini which Apache uses.
Edit this php.ini:
c:\wamp\bin\apache\apache2.2.8\bin\php.ini
Find the following lines (fresh from a new install):
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
Uncomment the second line (remove the semicolon) and change it to:
include_path = ".;c:\wamp\bin\php\php5.2.5\PEAR"
Restart Apache.
Your script should now work.
By the way, are you sure your ISP's SMTP server requires you to present a username and password? Usually ISPs do not require that. In that case, change the line
'auth' => true,
to
'auth' => false,
In addition, if you want to use the Mail class from the command line interface (CLI), you need to add the PEAR folder to include_path in the file c:\wamp\bin\php\php5.2.5\php.ini. Sending emails from scheduled scripts like database backup is very handy.
In both configurations, in case you were to use just the mail() function in PHP, you must edit the php.ini file and make sure that the the SMTP parameter contains the domain name or IP address of the STMP server to which your application sends the messages.
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from =
me@example.comHowever, your sample script sets the host address using the PEAR Mail class.
Be careful to scrub the email addresses for valid format to avoid surprises in the form of mail injection attempts. Do some reading on 'mail injection' and how to prevent it.
Regards,
toivo
Sydney, Australia
Edited 1 time(s). Last edit at 03/19/2008 12:31PM by toivo.