sisproor
10-21-2008, 12:15 PM
I have a php function to send email using Mail.php. I noticed that Mail.php was not installed by default, so I proceed installing it, but anything changed. This is how I call Mail.php:
<?php
require_once("Mail.php");
function mandarMail($subject,$nombre,$correo,$mensaje,$from )
{
$to = $nombre ."<info@sispro.org.bo>";
$replay=$correo;
$body = $mensaje;
$host = "mail.domain.com";
$username = "info+domain.com";
$password = "1234";
$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject,'Reply-To'=>$replay);
$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>Error: " . $mail->getMessage() . "</p>" . $to . " " . $from . " " . $body);
return false;
}
else
{
//echo("<p>Message successfully sent!</p>");
echo("estado=OK&");
return true;
}
}
<?php
require_once("Mail.php");
function mandarMail($subject,$nombre,$correo,$mensaje,$from )
{
$to = $nombre ."<info@sispro.org.bo>";
$replay=$correo;
$body = $mensaje;
$host = "mail.domain.com";
$username = "info+domain.com";
$password = "1234";
$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject,'Reply-To'=>$replay);
$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>Error: " . $mail->getMessage() . "</p>" . $to . " " . $from . " " . $body);
return false;
}
else
{
//echo("<p>Message successfully sent!</p>");
echo("estado=OK&");
return true;
}
}