Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Modelo para envio de emails
- */
- Load::lib('phpmailer');
- class Mail
- {
- /**
- *
- * Objeto que instanscia la clase PHPMailer
- * @var PHPMailer
- */
- private static $mail ;
- /**
- * Carga los datos para envio de correo
- * @param $remitente
- */
- public static function prepare(){
- self::$mail = new PHPMailer();
- self::$mail->IsSMTP();
- self::$mail->SMTPAuth =true;
- self::$mail->SMTPSecure = 'ssl';
- $reg = Config::read('ryca');
- self::$mail->Host = Config::get('ryca.mail.host');
- self::$mail->Port = Config::get('ryca.mail.port');
- self::$mail->From = Config::get('ryca.mail.from');
- self::$mail->Username = Config::get('ryca.mail.user');
- self::$mail->Password = Config::get('ryca.mail.passwd');
- }
- /**
- *
- * Indica el mensaje de mail y los destinatarios
- * @param $subject asunto del mail
- * @param $mails correos a enviar bajo la convencion nombre => email
- */
- public static function destinations($subject, $mails = array()){
- self::$mail->Subject = $subject;
- foreach ($mails as $name => $mails)
- {
- self::$mail->AddAddress($mails, $name);
- }
- }
- public static function message($body)
- {
- self::$mail->Body = $body;
- }
- public static function attachment( $files= array())
- {
- foreach ($files as $path => $file)
- {
- self::$mail->AddAttachment($path, $file);
- }
- }
- public static function send()
- {
- return self::$mail->Send();
- }
- public static function error()
- {
- return self::$mail->ErrorInfo;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement