简体   繁体   English

PHP邮件发送问题

[英]PHP Mail Sending Issue

I'm having a hard time getting the following code to run: 我很难让以下代码运行:

$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());
}

I have this in my php.ini: 我的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"

Have also tried with: 也尝试过:

sendmail_path = "/usr/sbin/sendmail -t -i"

I have verified that the server is setup correctly to send email by running this directly on the server echo "test" | mail -s "test mail" my@email.com 我已经通过直接在服务器上运行此命令,来验证服务器是否已正确设置为发送电子邮件echo "test" | mail -s "test mail" my@email.com echo "test" | mail -s "test mail" my@email.com and I received the email. echo "test" | mail -s "test mail" my@email.com ,我收到了电子邮件。

What can be going on, or more to the point... what am I missing? 可能会发生什么,或更重要的是...我想念什么?

sorry guys. 对不起大家。 I had it spelt wrong in mailconfig.ini 我在mailconfig.ini中拼写错误

changing "/urs/sbin/sendmail -t -i -f my@email.com" to "/usr/sbin/sendmail -t -i -f my@email.com" did the trick "/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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM