LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-23-2006, 08:43 PM   #1
juniorhere
LQ Newbie
 
Registered: Dec 2006
Posts: 7

Rep: Reputation: 0
Question Sendmail Problem :-( please help!


Hello,
I just registered, because I've got a sendmail problem on a dedicated server, shall I post the configs or what do you suggest?

Problem is, that all coming in via smtp is sent through fine, but messages I try to send via PHP mail() are not going through, error in root is "deferred: connection refused by [127.0.0.1]"

I guess I just have a block of wood in front of my head, can somebody help to remove it PLEASE!



update:

Code:
file "access"

localhost.localdomain RELAY
localhost RELAY
127.0.0.1 RELAY
myPOPIP RELAY (changed when accessing via POP you know - POP is working as well as SMTP like said...)
telnet works too on Port 25:

Code:
telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 rummels.de ESMTP Sendmail 8.13.4/8.13.4/Debian-3sarge1; Fri, 22 Dec 2006 21:53:12 +0100; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
and status of sendmail seems to be fine too:

Code:
# /etc/init.d/sendmail status
MSP: is run via cron (20m)
MTA: 8640 /usr/sbin/sendmail-mta -Am -L sm-mta -bd -q10m
UID        PID  PPID  C STIME TTY          TIME CMD
root      8640     1  0 22:32 ?        00:00:00 sendmail: MTA: accepting connections
QUE: Same as MTA
one thing I found (I just used several test commands and this is one result - there is no 127.0.0.1 there, :

Code:
# netstat -an|grep 25
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN
....tcp        0      0 serverip:25        220.174.224.223:2246    VERBUNDEN

etc.
like said, SMTP & POP are wonderful working, just this PHP mail() isn't, always the same error

update2:

I did some more tests now as suggested by other people, maybe this helps:

Code:
# sendmail -v -d8 -d38(E-Mail address blocked: See forum rules)
dsfsdfs
.
(E-Mail address blocked: See forum rules)... Connecting to [127.0.0.1] port 587 via relay...
(E-Mail address blocked: See forum rules)... Deferred: Connection refused by [127.0.0.1]
so there is the error again, on the other side:

Code:
# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 "myserver" ESMTP Sendmail 8.13.4/8.13.4/Debian-3sarge1; Sat, 23 Dec 2006 23:24:50 +0100; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
helo test
250 "myserver" Hello localhost [127.0.0.1], pleased to meet you
mail from:(E-Mail address blocked: See forum rules)
250 2.1.0(E-Mail address blocked: See forum rules)... Sender ok
rcpt to:(E-Mail address blocked: See forum rules)
250 2.1.5(E-Mail address blocked: See forum rules)... Recipient ok
data
354 Enter mail, end with "." on a line by itself
test message
.
250 2.0.0 kBNMOoZu004585 Message accepted for delivery
quit
221 2.0.0 myserver closing connection
Connection closed by foreign host.
this last one reached the email address fine, so via telnet it's working, via smtp it's working, just via sendmail directly & php not, this is very strange to me

maybe this helps you locating the problem thanks my friends!
 
Old 12-25-2006, 09:42 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Well I don't know how php send mail, but according to the error you get and the test you've done:
Quote:
# sendmail -v -d8 -d38(E-Mail address blocked: See forum rules)
dsfsdfs
.
(E-Mail address blocked: See forum rules)... Connecting to [127.0.0.1] port 587 via relay...
(E-Mail address blocked: See forum rules)... Deferred: Connection refused by [127.0.0.1]
I think that php uses sendmail's submission port (587). If that's the case, then edit your sendmail.cf and uncomment the following:
Code:
DaemonPortOptions=Port=587, Name =MSA, M=E
and restart sendmail.
 
Old 12-25-2006, 02:08 PM   #3
ScooterB
Member
 
Registered: Sep 2003
Location: NW Arkansas
Distribution: Linux Redhat 9.0, Fedora Core 2,Debian 3.0, Win 2K, Win95, Win98, WinXp Pro
Posts: 344

Rep: Reputation: 31
bathory, couldn't he just add for sendmail to listen on that port (587) as well as 25 and 110 in his config file?
 
Old 12-26-2006, 09:07 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
ScooterB
Port 110 is used by the popd daemon and has nothing to do with sendmail. Port 587 is the message submission port that is used by sendmail according to the release notes:
Quote:
"sendmail implements RFC 2476 (Message Submission), e.g., it
can now listen on several different ports.Use:
O DaemonPortOptions=Name=MSA, Port=587, M=E
to run a Message Submission Agent (MSA);
By default that port is open, but perhaps the OP has closed it, or the sendmail config that his distro uses has disabled it.

Last edited by bathory; 12-26-2006 at 09:16 AM.
 
Old 12-26-2006, 09:13 AM   #5
ScooterB
Member
 
Registered: Sep 2003
Location: NW Arkansas
Distribution: Linux Redhat 9.0, Fedora Core 2,Debian 3.0, Win 2K, Win95, Win98, WinXp Pro
Posts: 344

Rep: Reputation: 31
Gotcha, thanks!
 
Old 01-06-2007, 09:56 PM   #6
juniorhere
LQ Newbie
 
Registered: Dec 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for the help, I fixed it so far now, but the next problem occured

when I send out mail via php to my gmail account, it always goes into spam, because of some header problems I think, I included SPF also, which is recognized, but doesn't change the situation to the better (exactly same email delivered via smtp from the same server works out to "land" in the inbox, it's freakin....):


Code:
Delivered-To: my-address-at@gmail.com
Received: by 10.82.153.10 with SMTP id a10cs185450bue;
        Sat, 6 Jan 2007 18:05:47 -0800 (PST)
Received: by 10.67.29.12 with SMTP id g12mr14006613ugj.1168135547091;
        Sat, 06 Jan 2007 18:05:47 -0800 (PST)
Return-Path: <sender@mydomain.com>
Received: from mydomain.com (mydomain.com [MY-SERVERs-IP-HERE])
        by mx.google.com with ESMTP id u6si37493585uge.2007.01.06.18.05.46;
        Sat, 06 Jan 2007 18:05:47 -0800 (PST)
Received-SPF: pass (google.com: domain of sender@mydomain.com designates MY-SERVERs-IP-HERE as permitted sender)
Received: from mydomain.com (localhost [127.0.0.1])
	by mydomain.com (8.13.4/8.13.4/Debian-3sarge1) with ESMTP id l07261DL004032
	for <my-address-at@gmail.com>; Sun, 7 Jan 2007 03:06:02 +0100
Received: (from root@localhost)
	by mydomain.com (8.13.4/8.13.4/Submit) id l072613x004030;
	Sun, 7 Jan 2007 03:06:01 +0100
Date: Sun, 7 Jan 2007 03:06:01 +0100
Message-Id: <200701070206.l072613x004030@mydomain.com>
To: my-address-at@gmail.com
Subject: I got news for you
Reply-To: sender@mydomain.com
From: David <sender@mydomain.com>
the email via smtp (the one landing in the inbox at gmail has the following headers instead:

Code:
Delivered-To: my-address-at@gmail.com
Received: by 10.82.153.10 with SMTP id a10cs180353bue;
        Sat, 6 Jan 2007 15:02:32 -0800 (PST)
Received: by 10.67.121.15 with SMTP id y15mr31671422ugm.1168124551891;
        Sat, 06 Jan 2007 15:02:31 -0800 (PST)
Return-Path: <sender@mydomain.com>
Received: from mydomain.com (mydomain.com [MY-SERVERs-IP-HERE])
        by mx.google.com with ESMTP id 54si37319882ugp.2007.01.06.15.02.31;
        Sat, 06 Jan 2007 15:02:31 -0800 (PST)
Received-SPF: pass (google.com: domain of sender@mydomain.com designates MY-SERVERs-IP-HERE as permitted sender)
Received: from mylaptop ([MY-ADSL-IP-HERE])
	by mydomain.com (8.13.4/8.13.4/Debian-3sarge1) with SMTP id l06N2iSv029170
	for <my-address-at@gmail.com>; Sun, 7 Jan 2007 00:02:46 +0100
Message-ID: <000301c731e6$be0b28f0$0973a8c0@mylaptop>
From: "my name" <sender@mydomain.com>
To: <my-address-at@gmail.com>
like said, the subject + content of the mails is the same, just the headers coming from root@localhost (for the script?) seems the problem maybe, or what do you experienced users think? How can I change this problem to the better? A change in the php.ini or sendmail config? The way it is "working" at present is, that confirmation emails for comments etc. are going into spam of the commenting party and that's not good

Thanks again and in advance as well for your appreciated help!
 
Old 01-08-2007, 06:34 AM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Open your php.ini and look for the [mail function] section and especially the "Setup for Linux systems" part. Uncomment or edit the "sendmail_from" line to something like:
Code:
sendmail_from = sender@mydomain.com
Restart your webserver and test again to see if it works.

Regards

Last edited by bathory; 01-09-2007 at 03:31 AM.
 
Old 01-08-2007, 06:38 PM   #8
juniorhere
LQ Newbie
 
Registered: Dec 2006
Posts: 7

Original Poster
Rep: Reputation: 0
thanks, but there's only

Code:
; For Win32 only
sendmail_from = me@localhost.com
so where shall there be a similar linux command? I can't find it
 
Old 01-09-2007, 03:57 AM   #9
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Basically this option is for Win32 systems that don't use sendmail, but it should work also in linux. Change it to sender@mydomain.com to see if it's actually works.
If it doesn't, then you must set up your hostname correctly since php mail() function uses by default <apache_user>@<hostname> as from address. That's why you have root@localhost as sender. Take a look here for details. Also you can set "ServerName" in httpd.conf to host.mydomain.com.
 
Old 01-10-2007, 05:00 AM   #10
juniorhere
LQ Newbie
 
Registered: Dec 2006
Posts: 7

Original Poster
Rep: Reputation: 0
the hostname is correct (checked via hostname command), so that's not the problem, also changed the sendmail_from and it only changes well... nothing the headers remain the same (and yes, it was the right php.ini, checked with phpinfo() and the sendmail_from is chowing there, but not used, as it's a debian system and no windows, where smtp + sendmail_from make sense

so please, what can it be?
 
Old 01-10-2007, 07:33 AM   #11
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Perhaps it's a poor written php script. Anyway you can try the solutions posted here and here (it's the last post) regarding the php mail() function.

Last edited by bathory; 01-10-2007 at 07:34 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sendmail.mc and sendmail-cf problem. ChrisScott Linux - Software 1 11-26-2006 02:30 PM
Sendmail problem not_the_one Linux - Networking 0 01-24-2005 05:51 PM
Sendmail Problem eggoz Linux - General 2 04-01-2004 02:23 PM
problem processing sendmail.mc to sendmail.cf ...help... lucastic Linux - Networking 1 09-21-2003 11:08 AM
Sendmail problem: sm-client permissions problem d3funct Linux - Software 0 08-12-2003 06:00 PM


All times are GMT -5. The time now is 08:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration