[英]PHP Mail Sending Issue
我很難讓以下代碼運行:
$name = 'Kevin';
$company = 'nonw';
$website = 'none';
$email = 'my@email.com';
$phone = 'none';
$message = 'Just a test message.';
$message = "<ul>
<li><strong>From:</strong> $name</li>
<li><strong>Company:</strong> $company</li>
<li><strong>Website:</strong> $website</li>
<li><strong>Email:</strong> $email</li>
<li><strong>Phone:</strong> $phone</li>
</ul>
<p>$message</p>";
$subject = '[' . $sitename . '] New contact message from ' . $name . ' ( ' . $email . ' )';
$headers = 'From: ' . $sitename . ' <' . $to . '>\r\nReply-To: ' . $email . '\r\n';
$s = mail($subject, $message, $email, $to);
if($s){
echo '<div class="msg">Your message has been sent. Thank you for contacting us, someone will be in touch soon.</div>';
}else{
echo '<div class="err">There was an error sending your message. Please try again later.</div>';
print_r(error_get_last());
}
我的php.ini中有這個:
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "/usr/sbin/sendmail -t -i -f my@email.com"
也嘗試過:
sendmail_path = "/usr/sbin/sendmail -t -i"
我已經通過直接在服務器上運行此命令,來驗證服務器是否已正確設置為發送電子郵件echo "test" | mail -s "test mail" my@email.com
echo "test" | mail -s "test mail" my@email.com
,我收到了電子郵件。
可能會發生什么,或更重要的是...我想念什么?
對不起大家。 我在mailconfig.ini中拼寫錯誤
將"/urs/sbin/sendmail -t -i -f my@email.com"
更改為"/usr/sbin/sendmail -t -i -f my@email.com"
就可以了
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.