我是 PHP 新手,我必須使用 phpmailer 發(fā)送簡(jiǎn)歷。我發(fā)現(xiàn)錯(cuò)誤為“Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting ”。請(qǐng)更改代碼。我在我的代碼中使用 phpmailer。它在我第一次做的時(shí)候有效,但現(xiàn)在這段代碼會(huì)出錯(cuò)。<?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 關(guān)注
- 1015 瀏覽
添加回答
舉報(bào)
0/150
提交
取消