Ver Mensaje Individual
  #5 (permalink)  
Antiguo 05/01/2010, 15:37
albertrc
 
Fecha de Ingreso: febrero-2009
Mensajes: 443
Antigüedad: 15 años, 10 meses
Puntos: 1
Respuesta: phpmailer i gmail ocular mesaje si se envia correctamente

<form action="contactar.php" method="post" name="contactar" enctype="multipart/form-data">
<div>
<label for="correu">Correu <span class="obligatori">*</span></label>
<input type="text" name="correu" id="correu" maxlength="25" size="25" />
</div>

<div>
<label for="assumpte">Assumpte <span class="obligatori">*</span></label>
<input type="text" name="assumpte" id="assumpte" maxlength="25" size="25"/>
</div>

<div>
<label for="nom">Nom i Cognoms <span class="obligatori">*</span></label>
<input type="text" name="nom" id="nom" maxlength="25" size="15" />
</div>

<div>
<textarea type="text" id="missatge" name="missatge" cols="30" rows="10"></textarea>
<label for="missatge">Missatge <span class="obligatori">*</span></label>
</div>


<?php
//************************************************** *****************
//reCAPTCHA
//************************************************** *****************
require_once('recaptchalib.php');
$publickey = "******* ";
$privatekey = "********";

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;

# are we submitting the page?
if ($_POST["submit"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if ($resp->is_valid) {
echo "You got it!";
# in a real application, you should send an email, create an account, etc
} else {
# set the error code so that we can display it. You could also use
# die ("reCAPTCHA failed"), but using the error message is
# more user friendly
$error = $resp->error;
}
}
echo recaptcha_get_html($publickey, $error);
?>



<br/>
<div class="botones">
<input type="submit" value="Enviar" />
</div>

<?php

include("class.phpmailer.php");
include("class.smtp.php");
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

//try {

$mail->Host = "localhost"; // SMTP server

$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)

$mail->SMTPAuth = true; // enable SMTP authentication

$mail->SMTPSecure = "ssl"; // sets the prefix to the servier

$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server

$mail->Port = 465; // set the SMTP port for the GMAIL server

$mail->Username = "[email protected]"; // GMAIL username

$mail->Password = "**********"; // GMAIL password

$mail->AddAddress($_POST['correu'],$_POST['nom'] );
$mail->SetFrom('[email protected]', 'correo');
$mail->Subject=("correo2 ".$_POST['assumpte']);
$mail->MsgHTML($_POST['missatge']);


$mail->Send();


//echo "Message Sent OK</p>\n";

//} catch (phpmailerException $e) {

//echo $e->errorMessage(); //Pretty error messages from PHPMailer

//} catch (Exception $e) {

//echo $e->getMessage(); //Boring error messages from anything else!

//}

?>


</form>