LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Configuring my mail server (https://www.linuxquestions.org/questions/linux-newbie-8/configuring-my-mail-server-420256/)

juancha 02-28-2006 05:43 AM

Configuring my mail server
 
Hi

I posted on here previously with regards the fact I had written a php script to send an email. The email never arrives to my inbox.

This what I found in the mail log


tms1:/var/spool/exim4/msglog# cat *

2006-02-21 18:47:54 Received from www-data@ U=www-data P=local S=438

2006-02-21 18:47:56 juan_chandler@hotmail.com R=dnslookup T=remote_smtp: SMTP error from remote mailer after MAIL FROM:<www-data@> SIZE=1471: host mx3.hotmail.com [65.54.244.72]: 501 Invalid Address

Process failed (1) when writing error message to www-data@ (frozen)tms1:/var/spool/exim4/msglog#

After posting to another forum someone else mentioned that this happens because the mail server isn't configured correctly.

ie. 501 invalid address as the mail server isn't adding the from address to the domain.

Can someone advise me on how I go about re configuring the mail server.

here's the php code to send the email too.

Code:

<?php

$mail_to="juan_chandler@hotmail.com";
$mail_from="juan@go-torevieja.com";
$mail_sub="Emailing with php";
$mail_mesg="This is a test to see if I am able to email using php";

//Check for success/failure of delivery
if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from")){
echo "E-mail has been sent successfully to $mail_to";
}
else{
echo "Failed to send the E-mail from $mail_sub to $mail_to";
}
?>


timmeke 02-28-2006 07:06 AM

Are you using sendmail? Where does the "www-data@" come from? Is "www-data" the name of the user under which Apache (or PhP) is running when it sends the mail out?

Let's make one thing clear: the From: address you wrote in your PhP script goes into the mail header as the from address, but it's not the actual sender address that the remote mail server (in this case, hotmail's mx3 machine) takes into account. This address, called the envelope address, is different from your from: address.
This is shown by looking at the FROM:<...> part of the error message, which is the sender address, as seen by hotmail's mail server.

So, the point is, that you don't want to change your From: address. It's probably just find. It's the envelope address that seems to be wrong. It contains "www-data@", which is clearly an invalid mail address, hence the error you're seeing.

Normally, those envelope sender addresses get written automatically by your mail system and they contain your_user@your_computer.your_domain where your_computer is sometimes omitted.
So, my guess is that you're running PhP under the user "www-data", either via a webserver (Apache) or
directly. But your system didn't add your domain. So you may need to check some hostname configuration issues.

If I'm not mistaken, I've seen a similar issue on this forum for someone who didn't have the right entries in /etc/hosts.
So, could you please post the contents of:
/etc/hosts
/etc/host.conf
and the result of the hostname or uname -a commands?

As for the configuration of your mail server. Well, it could be that the mail server was wrongly configured to not add your domain at the end of the envelope address, which is not the default behaviour.
What mail server are you using?

Could you also please post your php.ini settings that are related to mails and SMTP, please?


All times are GMT -5. The time now is 11:16 PM.