Advertisement
Guest User

Untitled

a guest
Aug 1st, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <?php
  2. /**
  3. * Modelo para envio de emails
  4. */
  5. Load::lib('phpmailer');
  6. class Mail
  7. {
  8. /**
  9. *
  10. * Objeto que instanscia la clase PHPMailer
  11. * @var PHPMailer
  12. */
  13. private static $mail ;
  14.  
  15. /**
  16. * Carga los datos para envio de correo
  17. * @param $remitente
  18. */
  19. public static function prepare(){
  20. self::$mail = new PHPMailer();
  21. self::$mail->IsSMTP();
  22. self::$mail->SMTPAuth =true;
  23. self::$mail->SMTPSecure = 'ssl';
  24.  
  25. $reg = Config::read('ryca');
  26. self::$mail->Host = Config::get('ryca.mail.host');
  27. self::$mail->Port = Config::get('ryca.mail.port');
  28. self::$mail->From = Config::get('ryca.mail.from');
  29. self::$mail->Username = Config::get('ryca.mail.user');
  30. self::$mail->Password = Config::get('ryca.mail.passwd');
  31. }
  32.  
  33.  
  34.  
  35. /**
  36. *
  37. * Indica el mensaje de mail y los destinatarios
  38. * @param $subject asunto del mail
  39. * @param $mails correos a enviar bajo la convencion nombre => email
  40. */
  41. public static function destinations($subject, $mails = array()){
  42. self::$mail->Subject = $subject;
  43. foreach ($mails as $name => $mails)
  44. {
  45. self::$mail->AddAddress($mails, $name);
  46. }
  47.  
  48. }
  49.  
  50. public static function message($body)
  51. {
  52. self::$mail->Body = $body;
  53. }
  54.  
  55. public static function attachment( $files= array())
  56. {
  57. foreach ($files as $path => $file)
  58. {
  59. self::$mail->AddAttachment($path, $file);
  60. }
  61. }
  62.  
  63. public static function send()
  64. {
  65. return self::$mail->Send();
  66. }
  67.  
  68. public static function error()
  69. {
  70. return self::$mail->ErrorInfo;
  71. }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement