Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'PHPMailerAutoload.php';
- $mail = new PHPMailer;
- $mail->isSMTP(); //Aqui le decimos que es SMTP
- $mail->Host = 'smtp.gmail.com';
- $mail->SMTPAuth = true;// Necesitas autenticarte con tu correo
- $mail->Username = 'tuemail@gmail.com';
- $mail->Password = 'passworddelemail';
- $mail->SMTPSecure = 'tls'; //Aqui le indicas si necesita TLS y el puerto
- $mail->Port = 587;
- $mail->setFrom('tuemail@gmail.com', 'Email de From');
- $mail->addAddress('emaila@mail.com', 'Nombre');
- $mail->addReplyTo('tuemail@gmail.com', 'Email de respuesta');
- $mail->addCC('a@mail.com'); //Si quieres añadir CC
- $mail->addBCC('b@mail.com'); //Si quieres añadir BCC
- //Con addAttachment podemos añadir attachments
- $mail->addAttachment('path/to/file');
- $mail->addAttachment('path/to/file');
- //Indicamos que el cuerpo del mensaje va a ser un html
- $mail->isHTML(true);
- $mail->Subject = 'Asunto del email';
- $mail->Body = 'Cuerpo del mensaje en HTML';
- $mail->AltBody = 'Cuerpo del mensaje en texto por si el receptor no puede ver HTML (opcional)';
- //Enviamos email
- if(!$mail->send()) {
- //Mensaje no pudo ser enviado
- } else {
- //Mensaje enviado correctamente
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement