im trying to send an email just when somebody enters on a page. It's for paypal payment confirmation. You pay something and in the page where you see what you did an email is send automatically.
The code is the next:
function send_email($from, $to, $subject, $nombre,$apellido) {
$pagoReal = $_SESSION["Payment_Amount"];
$monedaReal = $_SESSION["currencyCodeType"];
$estado = $_SESSION['estado'];
$id = $_SESSION['idHash'];
$mail = new PHPMailer();
$mail->SMTPDebug=3;
$mail->IsSMTP();
$mail->Host = 'localhost';
$mail->CharSet = "UTF-8";
$mail->From = $from;
$mail->FromName = 'Notificación de pago via Paypal';
$mail->addAddress($to);
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->SMTPAuth = true;
$contenido = "<html><body>
<p>Han realizado un nuevo ingreso via Paypal</p><br>
Nombre del cliente: $nombre $apellido<br>
Cantidad que pagó: $pagoReal $monedaReal <br>
Estado de la reserva:$estado <br>
Enlace a la factura : href='xxxxx/$id<br>
</body></html>";
$mail->Subject = $subject;
$mail->Body = $contenido;
['tmp_name'],$_FILES['cv_contacto']['name']);
if (!$mail->Send()) {
echo 'Error enviando mensaje.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
return "Mailer Error: " . $mail->ErrorInfo;
} else {
return 1;
}
}
then i call the function
send_email('[email protected]', '[email protected]','Payment of '. $firstName." ".$lastName,$firstName,$lastName);
And I get this error
Error: authentication failed: generic failure 2016-07-11 14:20:51 SMTP ERROR: Password command failed: 535 5.7.8 Error: authentication failed: generic failure 2016-07-11 14:20:51 CLIENT -> SERVER: QUIT 2016-07-11 14:20:51 SERVER -> CLIENT: 221 2.0.0 Bye 2016-07-11 14:20:51 Connection: closed 2016-07-11 14:20:51 SMTP connect() failed. Error enviando mensaje.Mailer Error: SMTP connect() failed.
Any idea of what can i do?
Thanks!
$mail->SMTPAuth = false;
instead of true if the local server will let you relay mail.