我有一个托管在 GoDaddy 上的网站的 HTML 表单,我正在尝试允许用户使用联系表单通过我的网站与我联系,我已经创建了一个 smtp PHP 脚本,但它似乎不起作用,脚本运行并重新加载页面,但我没有收到此测试的任何收入邮件。
<?php
include('Mail.php');
$host = 'localhost';
$username = '******@***********.com';
$password = '*******';
$subject = 'Test';
$from = '******@*********.com';
$to = '******.*******@***.com';
$cc = 'person to CC';
$recipients = $to . ", " . $cc; //
$headers = array ('From' => $from,
'To' => $to,
'Cc' => $cc,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => false,
'username' => $username,
'password' => $password,
'port' => '25'
));
$mail = $smtp->send($recipients, $headers, $body);
if ( PEAR::isError($mail) ) {
echo("<p>Error sending mail:<br/>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message sent.</p>");
}
header("Location:contact-us.html");
?>