Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/03/2013, 15:51
Avatar de ZonaRLX
ZonaRLX
 
Fecha de Ingreso: enero-2011
Mensajes: 75
Antigüedad: 14 años, 2 meses
Puntos: 2
Respuesta: Problemas con mail()

Código PHP:
Ver original
  1. <?php
  2. //cambie las opciones aqui, coloque la cuenta de correo que dese establecer para enviar su correo
  3.  
  4. $your_email = "[email protected]";
  5. $your_smtp = "midominio.com";
  6. $your_smtp_user = "[email protected]";
  7. $your_smtp_pass = "1234567890";
  8. $your_website = "http://midominio.com";
  9.  
  10.  
  11. require("phpmailer/class.phpmailer.php");
  12.  
  13.  
  14. //function to check properly formed email address
  15. function isEmailValid($email)
  16. {
  17.   // checks proper syntax
  18.   if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $email))
  19.   {
  20.     return false;
  21.   }
  22.  
  23.   return true;
  24.  
  25. }
  26.  
  27.  
  28. //get contact form details
  29. $name = $_POST['name'];
  30. $email = $_POST['email'];
  31. $url = $_POST['url'];
  32. $comments = $_POST['comments'];
  33.  
  34.  
  35. //validate email address, if it is invalid, then returns error
  36.  
  37. if (!isEmailValid($email)) {
  38.     die('Invalid email address');
  39. }
  40.  
  41. //start phpmailer code
  42.  
  43. $ip = $_SERVER["REMOTE_ADDR"];
  44. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  45.  
  46.  
  47.  
  48. $response="Date: " . date("d F, Y h:i:s A",time()+ 16 * 3600 - 600) ."\n" . "IP Address: $ip\nURL: $url\nUser-agent:$user_agent\nName: $name\nContents:\n$comments\n";
  49. //mail("[email protected]","Contact form fakapster",$response, $headers);
  50.  
  51. $mail = new PHPmailer();
  52. $mail->SetLanguage("en", "phpmailer/language");
  53. $mail->From = $your_email;
  54. $mail->FromName = $your_website;
  55. $mail->Host = $your_smtp;
  56. $mail->Mailer   = "smtp";
  57. $mail->Password = $your_smtp_pass;
  58. $mail->Username = $your_smtp_user;
  59. $mail->Subject = "$your_website feedback";
  60. $mail->SMTPAuth  =  "true";
  61.  
  62. $mail->Body = $response;
  63. $mail->AddAddress($your_email,"$your_website admin");
  64. $mail->AddReplyTo($email,$name);
  65.  
  66.  
  67. if (!$mail->Send()) {
  68. echo "<p>There was an error in sending mail, please try again at a later time</p>";
  69. echo "<p>".$mail->ErrorInfo."</p>";
  70. } else {
  71.     echo "<p>Thanks for your feedback, <em>$name</em>! We will contact you soon!</p>";
  72. }
  73.  
  74. $mail->ClearAddresses();
  75. $mail->ClearAttachments();
  76.  
  77. ?>

este es el codigo que estoy usando. Espero me puedas apoyar con el...
ya intente de varios modos y no logro lo que necesito. :( me tiene con canas verdes este tema.