LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-04-2005, 03:33 AM   #1
NaX
LQ Newbie
 
Registered: Feb 2005
Location: South Africa
Distribution: FreeBSD/PCBSD
Posts: 17

Rep: Reputation: 0
Unhappy PHP and Sendmail setup. Help Needed!!!


Hi all.

I have been using linux on and off for the past year. I know a little more than a newbie. And I am loving it.

I need some major help. I have setup a Slackware 10 box on my works intranet as a php, mysql development server.
apache and php are working fine. I know need to be able to use the php mail function. Any email generated form php need to be forwarded to our freeBSD mail server and it will deliver the mail.

I have tried googling for php and sendmail and no luck.

I have never setup sendmail before. I have set the sendmail_path = /usr/sbin/sendmail in my php.ini and restarted apache.
I also set the # "Smart" relay host (may be null) DS172.24.96.205 in my sendmail.cf and restarted sendmail. The mail has never gotten delivered.

The last line in my maillog is:
Feb 4 10:19:09 UnixServer sendmail[1763]: j148J9Ja001763: from=nobody, size=213, class=0, nrcpts=0, msgid=200502040819.j148J9Ja001763@UnixServer, relay=nobody@localhost

I have also removed the default sendmail install using pkgtool and reinstalled it using this tutorial. hgriggs.com/sendmail.html and that did not work.
I though this would be a simple thing to setup considering that it just needs to forward mail to a another server.

Can some one please tell me step by step how to setup sendmail. My boss is getting a little edgy about how long I have spent on this issue.
Please help.

Last edited by NaX; 02-04-2005 at 06:07 AM.
 
Old 02-04-2005, 09:24 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Does the freeBSD mail server accept mail from your box?
If yes, then I guess the problem is that, if you use a web form to send mail via php, the user who tries to write in sendmail queue is "nobody" or whatever is the user under which runs your webserver (apache?). A quick fix is to change that user (in httpd.conf if you use apache) to the user thar runs sendmail (probably smmsp).
Take a look also at /var/log/mailog to see if you find what the problem is.

Regards
 
Old 02-06-2005, 04:14 AM   #3
NaX
LQ Newbie
 
Registered: Feb 2005
Location: South Africa
Distribution: FreeBSD/PCBSD
Posts: 17

Original Poster
Rep: Reputation: 0
The freeBSD box is our gateway , firewall and mail server. It is our POP and SMTP server. It accepts any smtp request form our internal network.

I am running Slackware 10, Apache, PHP, mySQL and trying to use sendmail.
Can you recommend a good Sendmail tutorial or howto.

Should the from=nobody read form=<form email address>.
I had a look at the mailq and it is empty.

I will check the send mail user in my httpd.conf.
 
Old 02-06-2005, 08:39 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
If you use the sendmail package that comes with Slackware the user/group that run sendmail is smmsp/smmsp. If not run:
Code:
ps aux|grep sendmail
to find out the sendmail user. Then find the group of that user from /etc/group.
Open your apache's httpd.conf and find the lines that define the user/group under which apache is running. It's something like:
Quote:
User nobody
Group nobody
Change the words nobody with the name of the user and group that runs sendmail and restart apache.
There is no need to change anything in your php.ini because php's mail function knows how to invoce sendmail to send emails.

Regards

Last edited by bathory; 02-06-2005 at 09:03 AM.
 
Old 02-07-2005, 02:04 AM   #5
NaX
LQ Newbie
 
Registered: Feb 2005
Location: South Africa
Distribution: FreeBSD/PCBSD
Posts: 17

Original Poster
Rep: Reputation: 0
Still no luck

I have changed the user and group in apache to smmsp still no change. The emails still do not get to me.

I have checked the maillog on the freeBSD box and the mail does not reach it.

This is the last few lines form my maillog on my Linux box

Quote:
Feb 4 10:19:09 UnixServer sendmail[1763]: j148J9Ja001763: from=nobody, size=213, class=0, nrcpts=0, msgid=<200502040819.j148J9Ja001763@UnixServer.sublime>, r
elay=nobody@localhost

Feb 7 09:07:56 UnixServer sm-mta[1475]: starting daemon (8.13.3): SMTP+queueing@00:25:00
Feb 7 09:07:57 UnixServer sm-msp-queue[1478]: starting daemon (8.13.3): queueing@00:25:00

Feb 7 09:36:01 UnixServer sendmail[1672]: j177a1Jq001672: from=smmsp, size=213, class=0, nrcpts=0, msgid=<200502070736.j177a1Jq001672@UnixServer.sublime>, re lay=smmsp@localhost
Should relay no be the bsd server or does that mean that smmsp is relaying through sendmail.


In my sendmail.cf file a have set Smart relay to:

Quote:
# "Smart" relay host (may be null)
DS172.24.96.205
Is this correct and can I use IP address instead of hostnames.

Is their a way I can manually test sendmail and make sendmail a open relay. I don't need to worry about security as it is a test server. It need to accept request form any internal address.

I have removed the default install of sendmail and installed form source. Should I rather install the default sendmail.
 
Old 02-07-2005, 04:05 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
I think that smart relay host does not work with IP addresses. So use the freeBSD hostname in the DS definition, or if you cannot resolve the IP to hostname try this
 
Old 02-07-2005, 04:45 AM   #7
NaX
LQ Newbie
 
Registered: Feb 2005
Location: South Africa
Distribution: FreeBSD/PCBSD
Posts: 17

Original Poster
Rep: Reputation: 0
I tried that using brackets with the IP address in the smart host and still no luck.
 
Old 02-07-2005, 05:03 AM   #8
NaX
LQ Newbie
 
Registered: Feb 2005
Location: South Africa
Distribution: FreeBSD/PCBSD
Posts: 17

Original Poster
Rep: Reputation: 0
Maybe I need to reinstall sendmail.

Do you know of any good HowTo's
I have been using this

or maybe I should go back to the default sendmail install.
 
Old 02-07-2005, 05:36 AM   #9
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
No need to reinstall. Just use the sendmail-slackware.mc file that slackware uses to create the sendmail.cf and add in that file the IP in brackets. Mind that you may have to uncomment the line about smart host (i.e. remove "dnl" in the front and put it at the end of the line). Then recreate the sendmail.cf.
Take a look at usr/share/sendmail/cf/cf/README how to create such file. Always take a backup of your original /etc/mail/sendmail.cf before doing any changes.
 
Old 02-07-2005, 09:28 AM   #10
NaX
LQ Newbie
 
Registered: Feb 2005
Location: South Africa
Distribution: FreeBSD/PCBSD
Posts: 17

Original Poster
Rep: Reputation: 0
I have had some joy and some more frustrations.

I reconfigured Sendmail. And still no luck.

Then tested sendmail using the mail command:

Code:
mail myemail@mydomain
subject: test
test
.
This sent me a email and it come through to my mailbox.

My maillog now looks like this:

Quote:
Feb 7 17:11:15 UnixServer sm-mta[28340]: j17FBF48028340: from=<root@unixserver>, size=445, class=0, nrcpts=1, msgid=<42078512.mailLV611X4HH@unixserve r.sublime>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]

Feb 7 17:11:15 UnixServer sendmail[28339]: j17FBFNV028339: to=myemail@mydomain, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=302 61, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (j17FBF48028340 Message accepted for delivery)

Feb 7 17:11:15 UnixServer sm-mta[28342]: j17FBF48028340: to=<myemail@mydomain>, ctladdr=<root@unixserver> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30445, relay=[172.24.96.205] [172.24.96.205], dsn=2.0.0, stat=Sent (Ok: queued as 099AD313D9C)
So now think that it just does not work when it is sent from apache//php.
When I send a email using php this is my mail log.


Quote:
Feb 7 17:40:50 UnixServer sendmail[28399]: j17FeosW028399: from=nobody, size=180, class=0, nrcpts=0, msgid=<200502071540.j17FeosW028399@unixserver>, relay=nobody@localhost
my php.ini
sendmail_path = /usr/sbin/sendmail

No I am thinking I need to pass sendmail some switches or It is storing these emails locally and not forwarding thing on

Last edited by NaX; 02-07-2005 at 09:43 AM.
 
Old 02-07-2005, 10:35 AM   #11
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Did you try to use system commands with php like system() or popen() instead of using
the built-in mail() function, that should work if it works at command line

More infos at www.php.net with the functions search field
 
Old 02-07-2005, 11:44 AM   #12
palletooru
LQ Newbie
 
Registered: Sep 2004
Location: warnagal,india
Distribution: red hat
Posts: 11

Rep: Reputation: 0
another question

Dear friends ,
I need to configure sendmail in Redhat 9.0 which can enable e-mail addesses with periods in between viz.


a.b@c.com

or

yahoo.rediff@hotmail.com

Please help me if u can
 
Old 02-07-2005, 01:57 PM   #13
NaX
LQ Newbie
 
Registered: Feb 2005
Location: South Africa
Distribution: FreeBSD/PCBSD
Posts: 17

Original Poster
Rep: Reputation: 0
I will try those commands, but the sites that I am testing and developing on this box will need to use the mail() function.

Is their any thing more I need to add to my php.ini other than the sendmail path.


Quote:
I need to configure sendmail in Redhat 9.0 which can enable e-mail addesses with periods in between viz.
Try running a sendmail test.

Testing sendmail.cf files

Code:
/usr/sbin/sendmail -bt
3,0 email-address
This will show you how sendmail reads the periods and the @.

Last edited by NaX; 02-08-2005 at 02:11 PM.
 
Old 02-07-2005, 02:23 PM   #14
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
You could also take the thing at a lower level and implement a personal mail() function which could open a tcp socket to talk with your freeBSD mail server
 
Old 02-09-2005, 06:15 AM   #15
NaX
LQ Newbie
 
Registered: Feb 2005
Location: South Africa
Distribution: FreeBSD/PCBSD
Posts: 17

Original Poster
Rep: Reputation: 0
Talking It's Working

I finally got it working and it ended up being something very simple and something I overlooked.

Sendmail was working fine for the begining. All I needed to do with Sendmail was set the "Smart" relay host.

Then in my php.ini I needed to set my path to sendmail.
This is what I set it to and this did not work.

Quote:
; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path = /usr/sbin/sendmail
In the comment it says that (default: "sendmail -t -i") . So I never supplied any arguments assuming it will use the default, but it started working when I add the arguments -t -i. So that means that it is not the default arguments but the recommended arguments.

So the correct Sendmail path is.

Quote:
; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path = /usr/sbin/sendmail -t -i
What lead me to this conclusion was that in my maillog messages that where successful had 3 entries in the maillog and in the first entry it had nrcpts=1 (no. of recipients), and entries for mails generated using php/apache it had only 1 entry in the maillog and nrcpts=0. Which means that it was not sending the messages.

Thanks for the Help guys.
 
  


Reply



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 masquerade help needed Rackemup Linux - General 2 03-05-2009 04:10 PM
php+ sendmail no good - python + sendmail ok nephish Linux - Networking 1 10-07-2005 01:19 PM
php and sendmail setup problems dotancohen Linux - Newbie 0 08-23-2005 06:31 PM
Sendmail with PHP setup!!! NaX Linux - Software 2 02-04-2005 08:08 AM
Sendmail Help needed please jester_69 Linux - General 4 12-15-2002 04:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:14 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
Open Source Consulting | Domain Registration