【发布时间】:2018-09-01 09:34:35
【问题描述】:
我有这个表单,可以将电子邮件发送到电子邮件。在 localhost 中它工作正常,当我将它上传到主机时,它给了我以下错误。
无法访问文件:SMTP 错误:无法连接到 SMTP 主机
电子邮件.php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$portal = $_POST['portal'];
$piso = $_POST['piso'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$incidencia = $_POST['incidencia'];
$message = $_POST['message'];
$archivo = $_FILES['adjunto'];
require("archivosformulario/class.phpmailer.php");
$mail = new PHPMailer();
$mail->From = $email;
$mail->FromName = $first_name;
$mail->AddAddress("micrreo@gmail.com"); // Dirección a la que llegaran los mensajes.
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "Incidencia ";
$mail->Body =
"Esto es un correo generado desde la web, si quiere mas informacion contacte con: correo@gmail.com \n<br".
"Nombre: $first_name \n<br />".
"Apellido: $last_name \n<br />".
"Portal: $portal \n<br />".
"Piso: $piso \n<br />".
"Email: $email \n<br />".
"Telefono: $phone \n<br />".
"Incidencia: $incidencia \n<br />".
"Mensaje: $message \n<br />";
$mail->AddAttachment($archivo['tmp_name'], $archivo['name']);
$mail->IsSMTP();
$mail->Host = "ssl://smtp.gmail.com:465"; // Servidor de Salida.
$mail->SMTPAuth = true;
$mail->Username = "micorreo@gmail.com"; // Correo Electrónico
$mail->Password = "mipasswd"; // Contraseña
if ($mail->Send()){
echo "<script>alert('bien');location.href ='javascript:history.back()';</script>";
}else{
echo "<script>alert('Error al enviar el formulario')</script>";
var_dump($_POST);
exit();
}
?>
对不起我的英语,我是西班牙人 非常感谢任何帮助我的人
【问题讨论】:
-
你好,我看到了这篇文章,但我的问题是不同的。我已经做了那个帖子所表明的
-
我认为我的问题是我尝试将文件发送到邮件,但我现在没有