Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.29 KB | None | 0 0
  1. require 'vendor/autoload.php'; //acá va la ruta donde dejaste la carpeta
  2.  
  3. $mail = new PHPMailer(true);
  4. try {
  5.     //SI VAS A ENVIAR POR SMTP ACTIVAS ESTO SI NO DEJALO ASI NO MAS
  6.     //$mail->SMTPDebug = 2;                                 // Enable verbose debug output
  7.     //$mail->isSMTP();                                      // Set mailer to use SMTP
  8.     //$mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
  9.     //$mail->SMTPAuth = true;                               // Enable SMTP authentication
  10.     //$mail->Username = 'user@example.com';                 // SMTP username
  11.     //$mail->Password = 'secret';                           // SMTP password
  12.     //$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  13.     //$mail->Port = 587;                                    // TCP port to connect to
  14.  
  15.     //Recipients
  16.     $mail->setFrom('from@example.com', 'Mailer');  // DE DONDE SALE EL MAIL
  17.     $mail->addAddress('joe@example.net', 'Joe User');     // A QUIEN LE LLEGA EL MAIL TIENES QUE PONERLOS DE A UNO
  18.     $mail->addAddress('ellen@example.com');               // IGual que arriba es lo mismo xD
  19.     $mail->addReplyTo('info@example.com', 'Information'); // SI QUIERES DEJAR UN REPLY
  20.     $mail->addCC('cc@example.com'); // COPIA
  21.     $mail->addBCC('bcc@example.com'); // COPIA OCULTA
  22.  
  23.     //Attachments
  24.     $mail->addAttachment('/var/tmp/file.tar.gz');         // SI QUIERES AGREGAR ARCHIVOS ADJUNTOS
  25.     $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // RECUERDA QUE ES LA RUTA NO LA URL
  26.  
  27.     //Content
  28.     $mail->isHTML(true);                                  // SI QUIERES QUE ACEPTE HTML (recomiendo dejarlo asi)
  29.     $mail->Subject = 'Here is the subject';  // SUBJECT
  30.     $mail->Body    = 'This is the HTML message body <b>in bold!</b>'; // MENSAJE, puedes poner cualquier html
  31.     $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; // esto es por si no se carga el html
  32.  
  33.     $mail->send();
  34.         echo 'Message has been sent'; // SI SE MANDA PUEDES PONER ALGUN MENSAJE ACÁ O ELIMINAR ESTA LINEA
  35. } catch (Exception $e) {
  36.     echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; // ESTO ES IMPORTANTE PORQUE TE VA A DECIR QUE ESTA MAL EN EL ENVIO DE CORREO ;)
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement