LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-28-2004, 08:43 AM   #1
davemar
Member
 
Registered: Mar 2004
Location: UK
Posts: 62

Rep: Reputation: 15
Sending mail with PHP and sendmail.


Couldn't work out which section this question is best suited, so I've plumped for the general one. Please be gentle with me!...

Very simply I'm trying to send some mail using mail() in a PHP page. Typical sort of code like:-

<?PHP
mail("santa@claus.com", "Xmas", "when is it");
?>

I've got PHP running fine with apache, so that side of things is OK. I know I've got sendmail running from doing a 'ps', but not sure how it is configured and what I need to do to get it working with PHP/apache.

I'm using a dialup connection (I know, but I'm poor!) and my ISP which we'll call "dailup.org" for now. Assume I've got an email account with that ISP called "dave@dailup.org" too.

So how to I sort out sendmail, to get this email to "santa@claus.com" from "dave@dailup.org"?

Hopefully this is all easy for you geniuses out there! I've hunted around for tutorials and postings but not come up with anything particularly clear.

I'm just after a simple "get me going" sort of answer for now, thanks.
 
Old 05-28-2004, 09:08 AM   #2
looseCannon
Member
 
Registered: Dec 2003
Location: Little Rock, AR
Distribution: Fedora Core 2, AIX, HP-UX, Solaris, Whitebox
Posts: 193

Rep: Reputation: 31
Go to www.php.net and look for the mail command on there. They have an example of what you are wanting to do.

There is a fourth argument you can pass called additional headers. In there you can set it so it looks like it came from someone other than you web server. I've done this in a couple of different php scripts without a problem.
 
Old 05-28-2004, 09:34 AM   #3
davemar
Member
 
Registered: Mar 2004
Location: UK
Posts: 62

Original Poster
Rep: Reputation: 15
There's a lot of postings on the "mail()" page on php.net! I couldn't really see anything which really explained how to use sendmail itself, rather lot of examples of PHP code, which I've got some grip on.
I did see one posting using a PEAR object which apparantly doesn't need sendmail, would that be a useful approach?
 
Old 05-28-2004, 09:54 PM   #4
looseCannon
Member
 
Registered: Dec 2003
Location: Little Rock, AR
Distribution: Fedora Core 2, AIX, HP-UX, Solaris, Whitebox
Posts: 193

Rep: Reputation: 31
You probably need to take a look inside your php.ini file, usually in /usr/local/lib. Skip down to about line 510, at least that is where it shows up for me. This is the like you need to uncomment and modify to fit your system. In most set ups I've dealt with before using the suggested setting, on the line 509, was adequate.

After changing this setting you'll need to cycle your web server for the change to become effective. That's all there is to it, pretty simple on *NIX, different for WIN32.
 
Old 06-01-2004, 08:15 AM   #5
davemar
Member
 
Registered: Mar 2004
Location: UK
Posts: 62

Original Poster
Rep: Reputation: 15
I edited php.ini to change the mail settings so it looked at sendmail, and #ed out the Win32 related lines; but this still doesn't do anything.

How do I find out what sendmail is actually doing? It just seems to running in the background (I see when I do a 'ps'), but is there anywhere I can look to see if it is sending emails out, or receiving information to do so?
 
Old 06-01-2004, 11:42 AM   #6
LuggerHouse
Member
 
Registered: May 2004
Location: Montreal,QC,Canada
Distribution: Fedora Core 7
Posts: 208

Rep: Reputation: 30
Hello,
from my experience, php mail() function is about as easy as SH mail software...

So did you try sending mail sith bash

mail -s test dave@dailup.org

If you receive that mail FINE! Php's mail() function will work...

Now if you cant send using mail from bash:

Usualy when installing sendmail and using a secure ISP you might have to setup mail relay in you sendmail.conf file

if I remember well the line is something like

DSmyprovider.mail.relay.com

where DSmyprovider.mail.relay.com si where to send mail.

I now use PostFix wich is easier to set up!!

Good Luck!
 
Old 06-04-2004, 07:52 AM   #7
davemar
Member
 
Registered: Mar 2004
Location: UK
Posts: 62

Original Poster
Rep: Reputation: 15
I tried the "mail" as you suggested and it seemed to make all the 'right noises', but no mail was sent.

I changed the DS setting in sendmail.cf as you suggested, but had to hazard a guess at what the relay name would be, but did nothing.

Is there anyway of checking what sendmail is attempting to do?

I might have a look at PostFix is it is easier as you suggest, but it'll be good to get sendmail doing something useful.
 
Old 06-04-2004, 08:00 AM   #8
LuggerHouse
Member
 
Registered: May 2004
Location: Montreal,QC,Canada
Distribution: Fedora Core 7
Posts: 208

Rep: Reputation: 30
You can also try something else to debug you situation:

mail -v -s test dave@dailup.org

and post the output here... (-v is for verbose )

Also note that the DS option should be set to the value your ISP tells you to put as SMPT (outg going mail) server in your mail client's (like outlook)

Dont give up!
 
Old 06-08-2004, 09:04 AM   #9
davemar
Member
 
Registered: Mar 2004
Location: UK
Posts: 62

Original Poster
Rep: Reputation: 15
I tried that, but it seems the -v option is for the version of mail, not the verbose mode. I looked at mail's option list but couldn't see a verbose option.
I assume there are very different versions of mail around.
 
Old 06-08-2004, 11:51 AM   #10
Pete M
Member
 
Registered: Aug 2003
Location: UK
Distribution: Redhat 9 FC 3 SUSE 9.2 SUSE 9.3 Gentoo 2005.0 Debian Sid
Posts: 657

Rep: Reputation: 30
davemar

tail -f /var/log/maillog

As root will show you what Sendmail is doing, then in another terminal try

mail -s test dave@dailup.org

I'm using Redhat by the way, your maillog may be a different directory

Pete
 
Old 06-11-2004, 04:48 PM   #11
davemar
Member
 
Registered: Mar 2004
Location: UK
Posts: 62

Original Poster
Rep: Reputation: 15
This is the output I get from the /var/log/mail file (editted accordingly!):-

Jun 11 22:48:35 pc01 sendmail[16182]: i5BMmXx16182: from=root, size=343, class=0, nrcpts=1, msgid=<20040611224832.A15052@mypc>, relay=root@localhost
Jun 11 22:48:36 pc01 sendmail[16187]: i5BMmXx16182: to=dave@dialup.org, ctladdr=root (0/0), delay=00:00:03, xdelay=00:00:00, mailer=relay, pri=30343, relay=smtp.dialup.org, dsn=4.0.0, stat=Deferred: Name server: smtp.dialup.org: host name lookup failure

The 'hostname lookup failure' sounds dodgy, what would cause that?
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sendmail - not sending mail movitto Linux - Software 9 09-19-2014 03:23 AM
sendmail not sending mail dtra Linux - Software 1 06-09-2005 07:47 PM
sending picture with mail/sendmail ziox Linux - Networking 1 01-17-2005 11:56 AM
Sending mail without sendmail geomonap Linux - Security 2 12-21-2004 01:32 AM
sendmail not sending mail clinger Linux - Software 8 07-30-2004 02:29 AM


All times are GMT -5. The time now is 06:07 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration