Foros del Web » Programando para Internet » PHP »

Formulrio pagina web no me envia el mail

Estas en el tema de Formulrio pagina web no me envia el mail en el foro de PHP en Foros del Web. Hola buenas haber si me podeis ayudar con este formulario, ya que no me llega el correo al mail..... <?php session_start(); include("php/simple-php-captcha/simple-php-captcha.php"); include("php/php-mailer/PHPMailerAutoload.php"); // Step ...
  #1 (permalink)  
Antiguo 27/11/2014, 10:59
 
Fecha de Ingreso: noviembre-2014
Mensajes: 9
Antigüedad: 9 años, 4 meses
Puntos: 0
Formulrio pagina web no me envia el mail

Hola buenas haber si me podeis ayudar con este formulario, ya que no me llega el correo al mail.....
<?php
session_start();

include("php/simple-php-captcha/simple-php-captcha.php");
include("php/php-mailer/PHPMailerAutoload.php");

// Step 1 - Enter your email address below.
$to = '[email protected]';

if(isset($_POST['emailSent'])) {

$subject = $_POST['subject'];

// Step 2 - If you don't want a "captcha" verification, remove that IF.
if (strtolower($_POST["captcha"]) == strtolower($_SESSION['captcha']['code'])) {

$name = $_POST['name'];
$email = $_POST['email'];

// Step 3 - Configure the fields list that you want to receive on the email.
$fields = array(
0 => array(
'text' => 'Name',
'val' => $_POST['name']
),
1 => array(
'text' => 'Email address',
'val' => $_POST['email']
),
2 => array(
'text' => 'Message',
'val' => $_POST['message']
),
3 => array(
'text' => 'Checkboxes',
'val' => implode($_POST['checkboxes'], ", ")
),
4 => array(
'text' => 'Radios',
'val' => $_POST['radios']
)
);

$message = "";

foreach($fields as $field) {
$message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
}

$mail = new PHPMailer;

$mail->IsSMTP(); // Set mailer to use SMTP
$mail->SMTPDebug = 0; // Debug Mode

// Step 4 - If you don't receive the email, try to configure the parameters below:

//$mail->Host = 'mail.yourserver.com'; // Specify main and backup server
//$mail->SMTPAuth = true; // Enable SMTP authentication
//$mail->Username = 'username'; // SMTP username
//$mail->Password = 'secret'; // SMTP password
//$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted

$mail->From = $email;
$mail->FromName = $_POST['name'];
$mail->AddAddress($to);
$mail->AddReplyTo($email, $name);

$mail->IsHTML(true);

$mail->CharSet = 'UTF-8';

$mail->Subject = $subject;
$mail->Body = $message;

// Step 5 - If you don't want to attach any files, remove that code below
if (isset($_FILES['attachment']) && $_FILES['attachment']['error'] == UPLOAD_ERR_OK) {
$mail->AddAttachment($_FILES['attachment']['tmp_name'], $_FILES['attachment']['name']);
}

if($mail->Send()) {
$arrResult = array('response'=> 'success');
} else {
$arrResult = array('response'=> 'error', 'error'=> $mail->ErrorInfo);
}

} else {

$arrResult['response'] = 'captchaError';

}

}
?>

Haber si veis algo gracias!
  #2 (permalink)  
Antiguo 27/11/2014, 16:45
 
Fecha de Ingreso: abril-2008
Mensajes: 25
Antigüedad: 15 años, 11 meses
Puntos: 0
Respuesta: Formulrio pagina web no me envia el mail

¿Estas haciendo la prueba en local? puede ser por eso..

te paso mi funcion de envio de mails.

function enviarMail( $apodo,$correo,$pin ){
// creamos el email
$denombre="Administrador del Sistema";
$deemail="[email protected]";
$sfrom="[email protected]"; //cuenta que envia
$sBCC="[email protected]"; //me envio una copia oculta
$sdestinatario="$correo"; //cuenta destino
$ssubject="Asunto:"; //subject
$shtml="Hola este es el cuerpo del mensaje";
$encabezados = "MIME-Version: 1.0\n";
$encabezados .= "Content-type: text/html; charset=iso-8859-1\n";
$encabezados .= "From: $denombre <$deemail>\n";
$encabezados .= "X-Sender: <$sfrom>\n";
$encabezados .= "BCC: <$sBCC>\n";
$encabezados .= "X-Mailer: PHP\n";
$encabezados .= "X-Priority: 1\n";
$encabezados .= "Return-Path: <$sfrom>\n";

mail($sdestinatario,$ssubject,$shtml,$encabezados) ;

}
  #3 (permalink)  
Antiguo 28/11/2014, 03:15
 
Fecha de Ingreso: septiembre-2014
Mensajes: 180
Antigüedad: 9 años, 6 meses
Puntos: 14
Respuesta: Formulrio pagina web no me envia el mail

¿No te devuelve ningún error? ¿Has consultado los logs del servidor de correo para ver si el mail sale, llega, etc?
__________________
Unelink.es - VPS, servidores dedicados, hosting y dominios. 10 años a tu lado.
  #4 (permalink)  
Antiguo 28/11/2014, 03:53
 
Fecha de Ingreso: noviembre-2014
Mensajes: 9
Antigüedad: 9 años, 4 meses
Puntos: 0
Respuesta: Formulrio pagina web no me envia el mail

Esta pagina esta publicada ya , y con el filezilla voy subiendo los archivos de php como puedo consultar los logs??? Perdon esque soy novato.... jeje

Gracias por las respuestas
  #5 (permalink)  
Antiguo 28/11/2014, 04:55
 
Fecha de Ingreso: noviembre-2014
Mensajes: 9
Antigüedad: 9 años, 4 meses
Puntos: 0
Respuesta: Formulrio pagina web no me envia el mail

Codigo html::

<div class="container">

<div class="row" id="contact">
<div class="col-md-6">

<div class="alert alert-success hidden" id="contactSuccess">
<strong>Success!</strong> Your message has been sent to us.
</div>

<div class="alert alert-danger hidden" id="contactError">
<strong>Error!</strong> There was an error sending your message.
</div>

<h2 class="short"><strong>Contacte</strong> amb nosaltres</h2>
<form id="contactForm" action="php/contact-form.php" method="POST">
<div class="row">
<div class="form-group">
<div class="col-md-6">
<label>Nom *</label>
<input type="text" value="" data-msg-required="Please enter your name." maxlength="100" class="form-control" name="name" id="name" required>
</div>
<div class="col-md-6">
<label>El seu email *</label>
<input type="email" value="" data-msg-required="Please enter your email address." data-msg-email="Please enter a valid email address." maxlength="100" class="form-control" name="email" id="email" required>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-12">
<label>Tema</label>
<input type="text" value="" data-msg-required="Please enter the subject." maxlength="100" class="form-control" name="subject" id="subject" required>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-12">
<label>Missatge *</label>
<textarea maxlength="5000" data-msg-required="Please enter your message." rows="10" class="form-control" name="message" id="message" required></textarea>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<input type="submit" value="Send Message" class="btn btn-primary btn-lg" data-loading-text="Loading...">
</div>
</div>
</form>
</div>
<div class="col-md-6">


php:
<?php
/*
Name: Contact Form
Written by: Okler Themes - (http://www.okler.net)
Version: 3.3.2
*/

session_cache_limiter('nocache');
header('Expires: ' . gmdate('r', 0));

header('Content-type: application/json');

// Step 1 - Enter your email address below.
$to = '[email protected]';

// Step 2 - Enable if the server requires SMTP authentication. (true/false)
$enablePHPMailer = false;

$subject = $_POST['subject'];

if(isset($_POST['email'])) {

$name = $_POST['name'];
$email = $_POST['email'];

$fields = array(
0 => array(
'text' => 'Name',
'val' => $_POST['name']
),
1 => array(
'text' => 'Email address',
'val' => $_POST['email']
),
2 => array(
'text' => 'Message',
'val' => $_POST['message']
)
);

$message = "";

foreach($fields as $field) {
$message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
}

// Simple Mail
if(!$enablePHPMailer) {

$headers = '';
$headers .= 'From: ' . $name . ' <' . $email . '>' . "\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";

if (mail($to, $subject, $message, $headers)){
$arrResult = array ('response'=>'success');
} else{
$arrResult = array ('response'=>'error');
}

// PHP Mailer Library - Docs: https://github.com/PHPMailer/PHPMailer
} else {

include("php-mailer/PHPMailerAutoload.php");

$mail = new PHPMailer;

$mail->IsSMTP(); // Set mailer to use SMTP
$mail->SMTPDebug = 0; // Debug Mode

// Step 3 - If you don't receive the email, try to configure the parameters below:

//$mail->Host = 'mail.yourserver.com'; // Specify main and backup server
//$mail->SMTPAuth = true; // Enable SMTP authentication
//$mail->Username = 'username'; // SMTP username
//$mail->Password = 'secret'; // SMTP password
//$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted

$mail->From = $email;
$mail->FromName = $_POST['name'];
$mail->AddAddress($to); // Add a recipient
$mail->AddReplyTo($email, $name);

$mail->IsHTML(true); // Set email format to HTML

$mail->CharSet = 'UTF-8';

$mail->Subject = $subject;
$mail->Body = $message;

if(!$mail->Send()) {
$arrResult = array ('response'=>'error');
}

$arrResult = array ('response'=>'success');

}

echo json_encode($arrResult);

} else {

$arrResult = array ('response'=>'error');
echo json_encode($arrResult);

}
?>



ffff haber si encontrais algo

Etiquetas: envia, formulario, html, mail
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:14.