Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'vendor/autoload.php'; //acá va la ruta donde dejaste la carpeta
- $mail = new PHPMailer(true);
- try {
- //SI VAS A ENVIAR POR SMTP ACTIVAS ESTO SI NO DEJALO ASI NO MAS
- //$mail->SMTPDebug = 2; // Enable verbose debug output
- //$mail->isSMTP(); // Set mailer to use SMTP
- //$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
- //$mail->SMTPAuth = true; // Enable SMTP authentication
- //$mail->Username = 'user@example.com'; // SMTP username
- //$mail->Password = 'secret'; // SMTP password
- //$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- //$mail->Port = 587; // TCP port to connect to
- //Recipients
- $mail->setFrom('from@example.com', 'Mailer'); // DE DONDE SALE EL MAIL
- $mail->addAddress('joe@example.net', 'Joe User'); // A QUIEN LE LLEGA EL MAIL TIENES QUE PONERLOS DE A UNO
- $mail->addAddress('ellen@example.com'); // IGual que arriba es lo mismo xD
- $mail->addReplyTo('info@example.com', 'Information'); // SI QUIERES DEJAR UN REPLY
- $mail->addCC('cc@example.com'); // COPIA
- $mail->addBCC('bcc@example.com'); // COPIA OCULTA
- //Attachments
- $mail->addAttachment('/var/tmp/file.tar.gz'); // SI QUIERES AGREGAR ARCHIVOS ADJUNTOS
- $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // RECUERDA QUE ES LA RUTA NO LA URL
- //Content
- $mail->isHTML(true); // SI QUIERES QUE ACEPTE HTML (recomiendo dejarlo asi)
- $mail->Subject = 'Here is the subject'; // SUBJECT
- $mail->Body = 'This is the HTML message body <b>in bold!</b>'; // MENSAJE, puedes poner cualquier html
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; // esto es por si no se carga el html
- $mail->send();
- echo 'Message has been sent'; // SI SE MANDA PUEDES PONER ALGUN MENSAJE ACÁ O ELIMINAR ESTA LINEA
- } catch (Exception $e) {
- 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 ;)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement