Foros del Web » Programando para Internet » PHP »

PHP OO agregar clase phpmailer

Estas en el tema de agregar clase phpmailer en el foro de PHP en Foros del Web. hola amigos estoy tratando de agregar una clase tipo php mailer y no logro hacerla funcionar: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código PHP: Ver original <?php class MailManager ...
  #1 (permalink)  
Antiguo 13/09/2014, 23:27
Avatar de arcanisgk122  
Fecha de Ingreso: junio-2010
Mensajes: 755
Antigüedad: 13 años, 10 meses
Puntos: 28
Pregunta agregar clase phpmailer

hola amigos estoy tratando de agregar una clase tipo php mailer y no logro hacerla funcionar:

Código PHP:
Ver original
  1. <?php
  2. class MailManager{
  3.     private $email;
  4.     function __construct(){
  5.         $this   ->  email   =   new PHPMailer();
  6.     }
  7.     function regmail($username,$email,$nombre,$telf,$country,$date){
  8.         $mail   =   $this ->    email       ->  IsSMTP();
  9.         $subject    = _SUBJECT;
  10.         $mail   =   $this ->    From        = 'email';
  11.         $mail   =   $this ->    Username    = 'email';
  12.         $mail   =   $this ->    FromName    = 'nombre';
  13.         $mail   =   $this ->    Password    = 'password';
  14.         $mail   =   $this ->    Host        = _HOST;
  15.         $mail   =   $this ->    SMTPAuth    = _SMTPAUTH;
  16.         $mail   =   $this ->    SMTPSecure  = _SMTPSECURE;
  17.         $mail   =   $this ->    SMTPDebug   = _SMTPDEBUG;
  18.         $mail   =   $this ->    Port        = _PORT;
  19.         $mail   =   $this ->    Subject     = "
  20.                                 $subject Cuenta Creada para: $nombre";
  21.         $mail   =   $this ->    AltBody     = "
  22.                                 Para ver Este mensaje Active la opcion HTML!";
  23.         $body   =   "<br><br>
  24.                     Hola, se a creado una cuenta en WebPOS Panama para su acceso.<br>
  25.                     <br>
  26.                     Informacion:
  27.                     Username: $username<br>
  28.                     Nombre de usuario: $nombre<br>
  29.                     E-Mail: $email<br>
  30.                     Telefono: $telf<br>
  31.                     Fecha de Registro: $date<br><br>
  32.                     Contraseña: 123456<br><br>
  33.                     <h2>Recuerde Cambiar la contraseña.</h2>
  34.         ";
  35.         $mail   =   $this   ->  email   ->  MsgHTML($body);
  36.        
  37.         if(!$mail-> $this ->    email   ->   Send()) {
  38.             echo "Mailer Error: " . $mail->ErrorInfo;
  39.         }else{
  40.             echo "Message sent!";  
  41.         }
  42.     }
  43. }
  44. ?>

me sale error undefined mail... y otros mas
__________________
Cooler Master Gladiator 600 - AMD PHENOM II X4 955 @ 3.5GHZ
GA-MA78GM-US2H - Super Talent 800 2GB x 2 Dual, (Unganged)
PSU Cooler Master eXtreme Power Plus 500W - Saphire R7-260OC-2GB
  #2 (permalink)  
Antiguo 15/09/2014, 21:09
Avatar de arcanisgk122  
Fecha de Ingreso: junio-2010
Mensajes: 755
Antigüedad: 13 años, 10 meses
Puntos: 28
Respuesta: agregar clase phpmailer

he hecho algunos ajustes pero sigue dando problemas

me da un : SMTP connect() failed. una ayudita chiquitos

Código PHP:
Ver original
  1. <?php
  2. class MailManager{
  3.     private $Mail;
  4.     function __construct(){
  5.         $this   ->  Mail    =   new PHPMailer(true);
  6.     }
  7.     function regmail($username,$email,$nombre,$telf,$country,$date){
  8.         $Mail   =   $this ->    Mail        ->  IsSMTP();
  9.         $body   =   "<br><br>
  10.                         Hola, se a creado una cuenta en hosting para su acceso.<br>
  11.                         <br>
  12.                         Informacion:
  13.                         Username: $username<br>
  14.                         Nombre de usuario: $nombre<br>
  15.                         E-Mail: $email<br>
  16.                         Telefono: $telf<br>
  17.                         Fecha de Registro: $date<br><br>
  18.                         Contraseña: 123456<br><br>
  19.                         <h2>Recuerde Cambiar la contraseña.</h2>
  20.             ";
  21.         echo $body;
  22.         echo"paso uno ok";
  23.         try {
  24.             $Mail   =   $this ->    CharSet     = 'UTF-8';
  25.             $Mail   =   $this ->    Host        = 'smtp.gmail.com';
  26.             $Mail   =   $this ->    SMTPdebug   = 2;
  27.             $Mail   =   $this ->    SMTPAuth    = 'true';
  28.             $Mail   =   $this ->    SMTPSecure  = 'tls';
  29.             $Mail   =   $this ->    Port        = '587';
  30.             $Mail   =   $this ->    Username    = '[email protected]';
  31.             $Mail   =   $this ->    Password    = '123456';
  32.             $Mail   =   $this ->    Mail        ->AddAddress($email, $nombre);
  33.             $Mail   =   $this ->    Mail        ->SetFrom('[email protected]', 'julio pela la yuca');
  34.             $subject    = _SUBJECT;
  35.             $Mail   =   $this ->    Subject     = "
  36.                                     $subject Cuenta Creada para: $nombre";
  37.             $Mail   =   $this ->    AltBody     = "
  38.                                     Para ver Este mensaje Active la opcion HTML!";
  39.            
  40.             /*$Mail =   $this ->    body        =
  41.                         "<br><br>
  42.                         Hola, se a creado una cuenta en hosting para su acceso.<br>
  43.                         <br>
  44.                         Informacion:
  45.                         Username: $username<br>
  46.                         Nombre de usuario: $nombre<br>
  47.                         E-Mail: $email<br>
  48.                         Telefono: $telf<br>
  49.                         Fecha de Registro: $date<br><br>
  50.                         Contraseña: 123456<br><br>
  51.                         <h2>Recuerde Cambiar la contraseña.</h2>
  52.                         ";*/
  53.             //$body;
  54.             $Mail   =   $this ->    Mail        ->  Body = $body;
  55.             $Mail   =   $this ->    Mail        ->  Send();
  56.             echo "Message Sent OK<p></p>\n";
  57.         } catch (phpmailerException $e) {
  58.             echo"error 1";
  59.             echo $e->errorMessage(); //Pretty error messages from PHPMailer
  60.         } catch (Exception $e) {
  61.             echo"error 2";
  62.             echo $e->getMessage(); //Boring error messages from anything else!
  63.         }
  64.     }
  65. }
  66. ?>
__________________
Cooler Master Gladiator 600 - AMD PHENOM II X4 955 @ 3.5GHZ
GA-MA78GM-US2H - Super Talent 800 2GB x 2 Dual, (Unganged)
PSU Cooler Master eXtreme Power Plus 500W - Saphire R7-260OC-2GB

Etiquetas: clase, fecha, html, phpmailer, registro
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:03.