1 回答
TA贡献1789条经验 获得超8个赞
您正在混合 PHPMailer 语法和 PHP mail() 语法。
对于 PHPMailer,请在您的代码中使用以下内容。
<?php
$name = $_POST['name'];
$email = $_POST['email'];
use PHPMailer\PHPMailer\PHPMailer;
require 'vendor/autoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.hostinger.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'noreply@domain.com';
$mail->Password = 'password';
/* Set the mail sender. */
$mail->setFrom($email, $name);
/* Add a recipient. */
$mail->addAddress('noreply@domain.com', 'earningtoanimate');
/* Add a replyto. */
$mail->addReplyTo($email, $name);
/* Add a CC and Bcc. */
$mail->addCC('noreply2@domain.com', 'earningtoanimate2');
$mail->addBCC('noreply3@domain.com', 'earningtoanimate3');
/* Add email subject. */
$mail->Subject = 'Test Email';
/* Add email body. */
$mail->isHTML(TRUE);
$mail->Body = 'There goes your message.';
/* Finally send the mail. */
if(!$mail->send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
测试以上内容并提供您的反馈。注意,我没有测试代码。只是将它们写在这里,因此可以在需要时进行一些编辑。
- 1 回答
- 0 关注
- 222 浏览
添加回答
举报