gpt4 book ai didi

phpmailer - 无法发送邮件。邮件程序错误:SMTP connect()

转载 作者:行者123 更新时间:2023-12-02 04:32:18 25 4
gpt4 key购买 nike

这是Ketaki,我正在尝试从网站向管理人员发送反馈,但是以下发生了一些错误:
嗨,这是Ketaki,我正在尝试从网站向管理人员发送反馈,但是以下发生了一些错误:
嗨,这是Ketaki,我正在尝试从网站向管理人员发送反馈,但是以下发生了一些错误:

2017-11-29 09:02:56 Could not access file: /var/tmp/file.tar.gz 2017-11-29 09:02:56 Could not access file: /tmp/image.jpg 2017-11-29 09:02:56   SERVER -> CLIENT: 220 smtp.gmail.com ESMTP b33sm2613509wrg.48 - gsmtp 2017-11-29 09:02:56   CLIENT -> SERVER: EHLO shreephotovision.ml 2017-11-29 09:02:56  SERVER -> CLIENT: 250-smtp.gmail.com at your service, [185.27.134.45] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 2017-11-29 09:02:56  CLIENT -> SERVER: STARTTLS 2017-11-29 09:02:56  SERVER -> CLIENT: 220 2.0.0 Ready to start TLS 2017-11-29 09:02:56  CLIENT -> SERVER: EHLO shreephotovision.ml 2017-11-29 09:02:56  SERVER -> CLIENT: 250-smtp.gmail.com at your service, [185.27.134.45] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 2017-11-29 09:02:56 CLIENT -> SERVER: AUTH LOGIN 2017-11-29 09:02:56    SERVER -> CLIENT: 334 VXNlcm5hbWU6 2017-11-29 09:02:56  CLIENT -> SERVER: bWlsaW5kYmh1dmFkMTk4OEBnbWFpbC5jb20= 2017-11-29 09:02:56  SERVER -> CLIENT: 334 UGFzc3dvcmQ6 2017-11-29 09:02:56  CLIENT -> SERVER: bW5iQDI4MDc= 2017-11-29 09:02:57  SERVER -> CLIENT: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 b33sm2613509wrg.48 - gsmtp 2017-11-29 09:02:57  SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 b33sm2613509wrg.48 - gsmtp 2017-11-29 09:02:57   SMTP Error: Could not authenticate. 2017-11-29 09:02:57 CLIENT -> SERVER: QUIT 2017-11-29 09:02:57  SERVER -> CLIENT: 221 2.0.0 closing connection b33sm2613509wrg.48 - gsmtp 2017-11-29 09:02:57   SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

我收到此错误。

我的PHPMailer代码如下:-
<?php
$name = $_REQUEST['name'] ;
$mobile = $_REQUEST['mobile'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

require 'phpmailer/PHPMailerAutoload.php';

/* All the form fields should be here, name of the field should be between $_POST['HERE']; */
//$name = htmlspecialchars($_POST['name']);
//$email = htmlspecialchars($_POST['email']);
//$message = htmlspecialchars($_POST['message']);

$mail = new PHPMailer;
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'milindbhuvad1988@gmail.com'; // SMTP username
$mail->Password = '********'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('milindbhuvad1988@gmail.com', '');
$mail->addAddress('milindbhuvad1988@gmail.com', ''); // Add a recipient
$mail->addAddress('milindbhuvad1988@gmail.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML

$mail->Subject = 'You have received feedback from your website!';
$mail->Body = "
<strong>Name:</strong> $name <hr>
<strong>Name:</strong> $mobile <hr>
<strong>Email:</strong> $email <hr>
<strong>Message:</strong> $message <hr>";

$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
// echo 'Message has been sent';
?>
<script type="text/javascript">
alert('Thanks Your Feedback');
window.location.href='index.html';
</script>';
<?php
}
?>

最佳答案

示例代码中包含的文件不在您的PC上。

发表评论将解决问题

$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name

关于phpmailer - 无法发送邮件。邮件程序错误:SMTP connect(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47549196/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com