Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1.     public function send() {
  2.        
  3.         Load::lib('phpmailer');
  4.        
  5.         $mail = new PHPMailer();
  6.        
  7.         $mail->From = $this->post('mymail');
  8.          
  9.         //Nombre del Remitente
  10.         $mail->FromName = $this->post('myname');
  11.          
  12.         //Aqui le indicamos que vamos a utilizar un servidor smtp...
  13.         $mail->Mailer = "smtp";
  14.          
  15.         //Aqui se le indica el servidor smtp
  16.         $mail->SMTPDebug = 1;
  17.         $mail->SMTPAuth = true;
  18.         $mail->SMTPSecure = 'ssl';     
  19.         $mail->Host= 'smtp.gmail.com';     
  20.         $mail->Port = 465;     
  21.          
  22.         //Le Indicamos el usuarios con el cual vamos a hacer la negociación de
  23.         //identificación con el SMTP
  24.         $mail->Username = "*";
  25.          
  26.         //Le indicamos la contraseña del servidor SMTP
  27.         $mail->Password = "*";
  28.          
  29.         //establece el tiempo del servidor en Segundo
  30.         $mail->Timeout=30;
  31.          
  32.         //Establece un asunto en el mensaje
  33.         $mail->Subject= "Consulta web";
  34.          
  35.         //Añadiendo la Direccion de Correo electronico a la cual estara
  36.         //dirigido el mensaje
  37.         $mail->AddAddress("contactar@ccaballero.com");
  38.          
  39.         //Establecemos el cuerpo del mensaje en HTML
  40.         $mybody = '<p>';
  41.         $mybody .= '<br /><strong>Nombre:</strong>'.$_POST['myname'];
  42.         $mybody .= '<br /><strong>Email:</strong>'.$_POST['myemail'];
  43.         $mybody .= '<br /><strong>Consulta:</strong>'.$_POST['mymessage'];
  44.         $mybody .= '</p>';
  45.         $mail->Body=$mybody;
  46.          
  47.         //Aqui pasamos texto plano ya que algunos cliente no aceptan HTML
  48.         $mail->AltBody = "Este ejemplo es para ver como funciona PHPmailer desde KUMBIA";
  49.          
  50.         //Enviamos el correo
  51.         $exito = $mail->Send();
  52.         $intentos = 1;
  53.          
  54.         //esto se realizara siempre y cuando la var exito contenga como valor false
  55.         while ((!$exito) && $intentos < 5){
  56.            $exito = $mail->Send();
  57.            $intentos = $intentos +1;
  58.         }      
  59.        
  60.         // Anulamos la salida
  61.         $this->render (NULL, NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement