Link to home
Start Free TrialLog in
Avatar of x_terminat_or_3
x_terminat_or_3

asked on

Configure mail

HI all


When I try to send mail with the php send command it bounces.


Reason: my isp does not accept incomming mail from apache@localuser.localhost or something like that

Can I change this setting somewhere?
Avatar of troopern
troopern

You can change the PHP script to edit the FROM tag in the mailheader I think.
Somehting like:
<?
mail("user@domain.tld", "Test MAIL", "Test Mail", "From: Name <user@domain.tld>");
?>

Probably your ISP is set to only allow sends to/from FQDN's
At this point we don't know if your ISP is objecting to the envelope sender address (apache@localhost.localdomain), ow whether they object to the hostname offered in the SMTP connection (localhost.localdomain). To fix the envelope sender issue you can set the from address in the mail() call in PHP, something like:

mail("nobody@example.com", "the subject", $message, "From: webmaster@$SERVER_NAME\r\n",
          "-fwebmaster@$SERVER_NAME");

To solve the hostname issue you'd need to configure your server with a valid hostname. In the case of an ISP customer the machine may need to have the hostname that a reverse lookup of your IP returns. Some ISP's aren't as picky and any valid hostname will work. Of course it should be a hostname in a domain you own.
Avatar of x_terminat_or_3

ASKER

yeah but the thing is, here is the script I use:

  $to=$where;
  $subject="message title";
  $message="messagebody";
  $headers  = "MIME-Version: 1.0\r\n";
  $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
  /* additional headers */
  $headers .= "To: $where\r\n";
  $headers .= "From: Inschrijvingsrobot www.vlaamse-kern.com\r\n";
  $headers .= "Return-Path: Webrobot@vlaamse-kern.com\r\n";
  $headers .=  "Reply-to: webmeester@vlaamse-kern.com\r\n";
  /* and now mail it */
  $res=mail($to, $subject, $message, $headers);


As you can see, the string "apache" or "localuser" or "localdomain" is not here.  So where does it come from?  Where can it be changed?
Because you don't explicity set the envelope sender (-fInschrijvingsrobot www.vlaamse-kern.com) in the mail() call the current user (apache) and what 'hostname' returns (localhost.localdomain) will be automatically used.
how can I change this?
SOLUTION
Avatar of jlevie
jlevie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I found it!  I changed it in network properties on host aliases!


But how come it takes almost a minute for the sendmail to execute itself?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It does have a fixed IP

81.xxx.xxx.168.250

I have a registered domain www.mydomain.com but my isp hasn't linked it to my fixed ip yet.  

so my /etc/hosts file should look like what:

127.0.0.1  localhost.localdomain localhost
81.xxx.xxx.168.250  what do I fill here?

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
but what do you mean if that's what I've set hostname to return.


Sorry if I ask so much, but I have 0 exp with linux.  I'm a bit misformed after 14 years of commercial software (read ms) ;-)



Ramses
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok.  I think I understand but where do I set the hostname?
What Linux are you running?
Fedora test 3
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So, I try to send mail with the server (to test) right.

This is my hosts file:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1      localhost.localdomain      localhost
81.xx.168.250      ramses      mydomain.com

In all logic, when I connect (on the sever) to the server by typing its IP in the addressbar of the browser, and then try to sendmail trough php, the IP that sendmail sees is the 81.xx.168.250 right, and that one's in the hosts file so it shouldn' t time out... but it does!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
why does it have to say ramses.mydomain.com ?  


Anyway, I did what you said and STILL it takes two minutes just to send the message.

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1      localhost.localdomain      localhost
81.xx.168.250      ramses.mydomain.com ramses
Here are the headers of a message I sent via the php script

X-Apparently-To: xxxxxxxxxxxxxx@yahoo.fr via 216.xxx.yyy.99; Sun, 07 Nov 2004 07:06:33 -0800
X-Originating-IP: [81.xx.168.250]
Return-Path: <apache@mydomain.com>
Received: from 81.xx.168.250  (EHLO mydomain.com) (81.220.168.250) by mta103.mail.sc5.yahoo.com with SMTP; Sun, 07 Nov 2004 07:06:33 -0800
Received: from mydomain.com (localhost.localdomain [127.0.0.1]) by mydomain.com (8.13.1/8.13.1) with ESMTP id iA7EpnB8014873 for <xxxxxxxxxxxxxx@yahoo.fr>; Sun, 7 Nov 2004 15:53:04 +0100
Received: (from apache@localhost) by mydomain.com (8.13.1/8.13.1/Submit) id iA7Epin3014862; Sun, 7 Nov 2004 15:51:44 +0100

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I DID!

Tell me, when I stop the sendmail service, and then try to sendmail trough the php script, it executes instantly, but when looking in the log, it get's refused.  Should sendmail be configured to start as a service with the system?

Here is the log

Nov  7 18:51:54 ramses sendmail[5224]: iA7Hpso0005224: from=apache, size=1405, class=0, nrcpts=1, msgid=<200411071751.iA7Hpso0005224@ramses.mydomain.com>, relay=apache@localhost
Nov  7 18:51:54 ramses sendmail[5224]: iA7Hpso0005224: to=xxxxxxxxxx@yahoo.fr, ctladdr=apache (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31405, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
jlevie, this is getting heavy....

Can you tell me how to setup the system?
what should be in php.ini (for the sendmail) ?
how should I configure apache (for the sendmail) ?
how should I configure sendmail ?

Maybe this approach will be easier instead of trying to find an error.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
jlevie

Tell me.  I did do these settings, but I found out that it's not  a www domain name.  My domain is not www.mydomain.com but just http://mydomain.com

When I go in my browser and type http://mydomain.com/   I come at my site, but when I click a relative link it's going to www.mydomain.com




SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for your help jlevie.  Maybe it's not working because my isp didn't made the MX stuff yet.  I mean, I don't control those things.  I said to my isp I want that domain and point it to that IP.  But he only created the domain up to now...


Anyway, Thank you for your continued input.



With kind regards



Ramses (x_terminat_or_3)