Código PHP:
<?php
$jdir="jlib";
class jmail{
var $from_email;
var $password;
var $from_name;
function __construct($from_email,$password,$from_name){
$this->From=$from_email;
$this->Password=$password;
$this->FromName=$from_name;
}
function send_email($subject,$to,$body){
include(GLOBALS("jdir")."/class.phpmailer.php");
$mail = new PHPMailer();
$mail->SetLanguage("es");
$mail->From = $this->From;
$mail->FromName = $this->FromName;
$mail->Subject = $subject;
foreach($to as $tos){$mail->AddAddress($tos[0],$tos[1]);}
$mail->Body = $body;
if (!$mail -> Send ()){echo "Error: ".$mail->ErrorInfo;}
else {echo "Mensaje enviado exitosamente";}
}
function send_gmail($subject,$to,$body){
include(GLOBALS("jdir")."/class.phpmailer.php");
include(GLOBALS("jdir")."/class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = $this->From;
$mail->Password = $this->Password;
$mail->From = $this->From;
$mail->FromName = $this->FromName;
$mail->Subject=$subject;
$mail->MsgHTML($body);
foreach($to as $tos){$mail->AddAddress($tos[0],$tos[1]);}
$mail->IsHTML(true);
if(!$mail->Send()) {echo "Error: ".$mail->ErrorInfo;}
else {echo "Mensaje enviado exitosamente";}
}
}
?>
si tiene algun sugerencia para mejorar esta clase se lo agradecería muchisimo.