我是 PHP 新手,我必须使用 phpmailer 发送简历。我发现错误为“Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting ”。请更改代码。我在我的代码中使用 phpmailer。它在我第一次做的时候有效,但现在这段代码会出错。<?php include('header.php');require 'PHPMailerAutoload.php';$message='';if(isset($_POST["submit"])){ $path='upload/'.$_FILES["resume"]["name"]; move_uploaded_file($_FILES["resume"]["tmp_name"], $path); $mail = new PHPMailer;$mail->SMTPDebug = 0; // Enable verbose debug output$mail->isSMTP(); // mailer to use SMTP$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers$mail->SMTPAuth = true; // Enable SMTP authentication$mail->Username = 'xyz01@gmail.com'; // SMTP username$mail->Password = 'mypasswordgoeshere'; // SMTP password$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted$mail->Port = 465; // TCP port to connect to$mail->From=$_POST['email'];$mail->FromName=$_POST['name'];$mail->setFrom($_POST['email']);$mail->addAddress('xyz01@gmail.com'); $mail->AddCC($_POST['name'],$_POST['email']);$mail->WordWrap=50;$mail->AddAttachment($path);$mail->Subject='application for job'; // Add a recipient // Name is optional$mail->addReplyTo($_POST['email']);$mail->isHTML(true); // Set email format to HTML//$mail->Subject = $_POST['subject'];$mail->Body = $_POST['message'];$mail->AltBody = $_POST['message'];if(!$mail->send()) { echo '<script>alert("Message could not be sent.")</script>'; echo 'Mailer Error: ' . $mail->ErrorInfo;} else { echo '<script>alert("Message has been sent"); window.location.href="career.php"; </script>';}}?>
- 2 回答
- 0 关注
- 974 浏览
添加回答
举报
0/150
提交
取消