在 SUSE Linux 上通过 PHP mail() 和 postfix 发送邮件时,我收到“550 发件人被管理员拒绝”错误。所有邮件都出现在 /var/mail/root 中,但未传递到电子邮件地址。
Content-Description: Delivery report
Content-Type: message/delivery-status
Reporting-MTA: dns; linux.local
X-Postfix-Queue-ID: E5B86BA
X-Postfix-Sender: rfc822; [email protected]
Arrival-Date: Wed, 12 Oct 2011 11:40:32 +0200 (CEST)
Final-Recipient: rfc822; [email protected]
Action: failed
Status: 5.0.0
Remote-MTA: dns; mx01.kundenserver.de
Diagnostic-Code: smtp; 550 sender rejected by administrator
--E5B86BA.1318412433/linux.local
Content-Description: Undelivered Message
Content-Type: message/rfc822
Return-Path: <[email protected]>
Received: by linux.local (Postfix, from userid 30)
id E5B86BA; Wed, 12 Oct 2011 11:40:32 +0200 (CEST)
To: [email protected]
Subject: Subject: test
X-PHP-Originating-Script: 0:mailtest.php
From: [email protected]
Message-Id: <[email protected]>
Date: Wed, 12 Oct 2011 11:40:32 +0200 (CEST)
test
一周前,我将 /etc/postfix/main.cf 中的 inet_interfaces 从 localhost 更改为 all,然后可以通过 php 发送邮件。但是现在它停止工作了。
~ # postconf -n
alias_maps = hash:/etc/aliases
biff = no
canonical_maps = hash:/etc/postfix/canonical
command_directory = /usr/sbin
config_directory = /etc/postfix
content_filter =
daemon_directory = /usr/lib/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
defer_transports =
delay_warning_time = 1h
disable_dns_lookups = no
disable_mime_output_conversion = no
html_directory = /usr/share/doc/packages/postfix-doc/html
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mail_spool_directory = /var/mail
mailbox_command =
mailbox_size_limit = 0
mailbox_transport =
mailq_path = /usr/bin/mailq
manpage_directory = /usr/share/man
masquerade_classes = envelope_sender, header_sender, header_recipient
masquerade_domains =
masquerade_exceptions = root
message_size_limit = 0
message_strip_characters = \0
mydestination = $myhostname, localhost.$mydomain
myhostname = linux.local
mynetworks_style = subnet
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/packages/postfix-doc/README_FILES
relay_domains = $mydestination, hash:/etc/postfix/relay
relayhost =
relocated_maps = hash:/etc/postfix/relocated
sample_directory = /usr/share/doc/packages/postfix-doc/samples
sender_canonical_maps = hash:/etc/postfix/sender_canonical
sendmail_path = /usr/sbin/sendmail
setgid_group = maildrop
smtp_enforce_tls = no
smtp_sasl_auth_enable = no
smtp_tls_session_cache_database = btree:/var/lib/postfix/smtpd_tls_session_cache
smtp_tls_session_cache_timeout = 3600s
smtp_use_tls = no
smtpd_client_restrictions =
smtpd_helo_required = no
smtpd_helo_restrictions =
smtpd_recipient_restrictions = permit_mynetworks,reject_unauth_destination
smtpd_sasl_auth_enable = no
smtpd_sender_restrictions = hash:/etc/postfix/access
smtpd_use_tls = no
strict_8bitmime = no
strict_rfc821_envelopes = no
transport_maps = hash:/etc/postfix/transport
unknown_local_recipient_reject_code = 550
virtual_alias_domains = hash:/etc/postfix/virtual
virtual_alias_maps = hash:/etc/postfix/virtual
为了完整性,我使用这个 PHP 脚本来测试 sendmail:
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("[email protected]", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailtest.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>
答案1
更改myhostname = linux.local
为有用的内容。您实际存在的域名是可以接受的。