Page 1 of 1

Mail library

Posted: Wed Aug 27, 2008 9:08 pm
by steve_t
I am having trouble getting my php (ver 5) to send mail. - but I am pretty new to php

My php program below dies at the include "Mail.php" line, indicating that it cant find this file. Yet it seems I need this to set up smtp host, email user/password etc settings

Can anyone provide a complete example of sending out an email with an attached plain text file
thx!
---------------------------------------------------------
<html>
<body>
Test email<br>

<?php
require "Mail.php";

$From='xx';
$Subject='Test Message';
$Body='This is a test message';

$Host='xx.com';
$User='xx';
$Pass='xx';

$To='xx';

echo "To: $To Host: $Host<br>\n";

$Headers['from']=$From;
$Headers['subject']=$Subject;

$Params['host']=$Host;
$Params['auth']=true;
$Params['username']=$User;
$Params['password']=$Pass;


$smtp =& Mail::factory('smtp',$Params);
$mail -> send($To,$Headers,$Body);

if (PEAR::isError($mail)) { echo " ".$mail->getMessage();}
else { echo "Message successfully sent";}

?>

</body>
</html>