Advertisement
Guest User

Untitled

a guest
Apr 17th, 2017
728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. require_once("class.phpmailer.php");
  2. require_once('class.smtp.php');
  3. $mail = new PHPMailer();
  4. $mail­->IsSMTP();
  5. $mail-­>SMTPDebug = 2;
  6. $mail-­>SMTPAuth = true;
  7. $mail-­>SMTPSecure = "ssl";
  8. //indico el servidor de Gmail para SMTP
  9. $mail-­>Host = "smtp.gmail.com";
  10. //indico el puerto que usa Gmail
  11. $mail-­>Port = 465;
  12. //indico un usuario / clave de un usuario de gmail
  13. $mail­->Username = "usuarioX";
  14. $mail-­>Password = "passwordX";
  15. $mail­->SetFrom('correo@gmail.com', 'Nombre');
  16. $mail­->AddReplyTo("correo@gmail.com","Nombre");
  17. $mail­->Subject = "Asunto del correo";
  18. $mail-­>MsgHTML("Hola, este es el cuerpo del mensaje!");
  19. //indico destinatario
  20. $address = "correoDestino@gmail.com";
  21. $mail­->AddAddress($address, "Mi nombre");
  22. if(!$mail­->Send()) {
  23. echo "Error al enviar: " . $mail-­>ErrorInfo;
  24. }
  25. else {
  26. echo "Mensaje enviado!";
  27. }
  28.  
  29. $mail­->SMTPDebug = 2;
  30.  
  31. $mail­->SMTPAuth = true;
  32.  
  33. <!--ENVIO DE EMAIL-->
  34. <?php
  35. require '../correo/PHPMailerAutoload.php';
  36. $mail = new PHPMailer();
  37.  
  38. //Variables recibidas:
  39. $nombre = $_POST['nombre'];
  40. $email = $_POST['email'];
  41. $mensaje = $_POST['mensaje'];
  42.  
  43. //Permite modo debug para ver mensajes de las cosas que van ocurriendo
  44. //$mail->SMTPDebug = 2;
  45.  
  46. //Hacer autenticación SMTP:
  47. $mail->SMTPAuth = true;
  48. $mail->SMTPSecure = "tls";//CON SSL NO ME FUNCIONO
  49.  
  50. //Indico el servidor de Gmail para SMTP:
  51. $mail->Host = "smtp.gmail.com";
  52.  
  53. //Indico el puerto que usa Gmail:
  54. $mail->Port = 587;
  55.  
  56. //Indico email de emisor:
  57. $mail->Username = "xxxx@gmail.com";
  58.  
  59. //Indico nombre de ususario de emisor:
  60. $mail->FromName = "Anonimo";
  61.  
  62. //Indico contraseña de emisor:
  63. $mail->Password = "xxxxxxxx";
  64.  
  65. //Cuerpo del mensaje por defecto.
  66. $body=$mensaje;
  67. $mail->Body = $body;
  68.  
  69. //Email al que puede responderte el usuario: '**Esto lo ve el usuario**':
  70. $mail->addReplyTo($email,$nombre);
  71.  
  72. //Asunto del mensaje:
  73. $mail->Subject = 'Contacto: Pagina_Web';
  74.  
  75. //Cuerpo del mensaje: 'html/txt'.
  76. $mail->msgHTML($mensaje);
  77. $mail->AltBody = $mensaje;
  78.  
  79. //Indico destinatario:
  80. $address = "xxxxx@gmail.com";
  81. $mail->addAddress($address, "Correo");
  82.  
  83. //Envio el email:
  84. if(!$mail->Send()) {
  85. //error en mensaje:'saco mensaje'
  86. echo "<p>Error al enviar mensaje.</p>"; /*. $mail->ErrorInfo;*/
  87. echo('<a href="javascript:history.back(1)">Volver Atrás</a>');
  88. } else {
  89. //Mensaje enviado:'saco mensaje'
  90. echo "<p>Mensaje enviado!!.</p>";
  91. echo('<a href="javascript:history.back(1)">Volver Atrás</a>');
  92. }
  93. ?>
  94.  
  95. [mail function]
  96. sendmail_from = xxxxxx@gmail.com
  97. sendmail_path =""C:xamppsendmailsendmail.exe" -t"
  98.  
  99. $mail­>SMTPDebug = 2;
  100.  
  101. $mail-­>IsSMTP();
  102. $mail­->SMTPDebug = 2;
  103. $mail­->SMTPAuth = true;
  104. $mail­->SMTPSecure = "ssl";
  105. //indico el servidor de Gmail para SMTP
  106. $mail-­>Host = "smtp.gmail.com";
  107. //indico el puerto que usa Gmail
  108. $mail­->Port = 465;
  109. //indico un usuario / clave de un usuario de gmail
  110. $mail­->Username = "usuarioX";
  111. $mail­->Password = "passwordX";
  112. $mail­->SetFrom('correo@gmail.com', 'Nombre');
  113. $mail­->AddReplyTo("correo@gmail.com","Nombre");
  114. $mail­->Subject = "Asunto del correo";
  115. $mail­->MsgHTML("Hola, este es el cuerpo del mensaje!");
  116. ...
  117. ...
  118.  
  119. $mail--­>IsSMTP();
  120. $mail­-->SMTPDebug = 2;
  121.  
  122. $mail->SMTPAuth = true;
  123. $mail->SMTPSecure = "tls";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement