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 = '[email protected]';
$mail->Password = 'password';
/* Set the mail sender. */
$mail->setFrom($email, $name);
/* Add a recipient. */
$mail->addAddress('[email protected]', 'earningtoanimate');
/* Add a replyto. */
$mail->addReplyTo($email, $name);
/* Add a CC and Bcc. */
$mail->addCC('[email protected]', 'earningtoanimate2');
$mail->addBCC('[email protected]', '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 關注
- 249 瀏覽
添加回答
舉報