[UPHPU] mail()
Lonnie Olson
lists at kittypee.com
Tue Jul 10 12:34:55 MDT 2007
Jonathan Duncan wrote:
>
> On 10 Jul 2007, at 09:06, Justin Giboney wrote:
>
>> Is there anything special that a server needs to have to run the
>> mail() function?
>> I have apache running on a mac (10.4.10) with no mail/smtp.
>>
>> this code (from various internet sources), seems to work, but I never
>> get a message
>>
>> <?php
>> $to = "graphics at westernbotanicals.com";
>> $subject = "Test mail";
>> $message = "Hello! This is a simple email messages.";
>> $from = "giboney at giboneydesigns.com";
>> $headers = "From: $from";
>> if(mail($to,$subject,$message,$headers)) {
>> echo "An e-mail was sent to $to with the subject: $subject";
>> } else {
>> echo "There was a problem sending the mail. Check your code and make
>> sure that the e-mail address $to is valid";
>> }
>> ?>
The mac uses postfix. Check the logs on your mac to determine the
reason. /var/log/mail.log It should detail the reason for the delivery
failure.
The default configuration for php should deliver to the local postfix
queue, which causes postfix to deliver the message directly to the
sender's MX server.
Common problems:
1. Outgoing SMTP is blocked by your firewall and/or ISP.
2. Other servers are considering it spam since it may be from a dynamic
address.
workarounds:
1. configure your local postfix instance to relay mail to a relayhost
(ISPs mailserver, office mailserver). see "relayhost" param in
/etc/postfix/main.cf
2. configure php to send mail to a specific mail server.
More information about the UPHPU
mailing list