Advertisement
Guest User

Untitled

a guest
Apr 17th, 2017
1,551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <?php
  2. require 'PHPMailerAutoload.php';
  3.  
  4. $mail = new PHPMailer;
  5.  
  6. $mail->isSMTP(); //Aqui le decimos que es SMTP
  7. $mail->Host = 'smtp.gmail.com';
  8. $mail->SMTPAuth = true;// Necesitas autenticarte con tu correo
  9. $mail->Username = 'tuemail@gmail.com';
  10. $mail->Password = 'passworddelemail';
  11. $mail->SMTPSecure = 'tls'; //Aqui le indicas si necesita TLS y el puerto
  12. $mail->Port = 587;
  13.  
  14.  
  15.  
  16. $mail->setFrom('tuemail@gmail.com', 'Email de From');
  17. $mail->addAddress('emaila@mail.com', 'Nombre');
  18. $mail->addReplyTo('tuemail@gmail.com', 'Email de respuesta');
  19. $mail->addCC('a@mail.com'); //Si quieres añadir CC
  20. $mail->addBCC('b@mail.com'); //Si quieres añadir BCC
  21.  
  22. //Con addAttachment podemos añadir attachments
  23. $mail->addAttachment('path/to/file');
  24. $mail->addAttachment('path/to/file');
  25.  
  26. //Indicamos que el cuerpo del mensaje va a ser un html
  27. $mail->isHTML(true);
  28.  
  29. $mail->Subject = 'Asunto del email';
  30. $mail->Body = 'Cuerpo del mensaje en HTML';
  31. $mail->AltBody = 'Cuerpo del mensaje en texto por si el receptor no puede ver HTML (opcional)';
  32.  
  33. //Enviamos email
  34. if(!$mail->send()) {
  35. //Mensaje no pudo ser enviado
  36. } else {
  37. //Mensaje enviado correctamente
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement