View Full Version : Sendmail and the mail command
macubergeek
03-24-2002, 01:10 PM
Hi
I want to use the mail command to send email from the command line like so:
mail -s "subject of email" emailaddress@whatever.com<textfile.txt
However I have the impression that I need to turn Sendmail on in order to do this.
Well I don't want to turn Sendmail on if I can avoid it, I won't want Sendmail to accept email just send it...
a. How do I get it to do this? How do I configure it?
b. What mail server do I aim this at? My isp's existing pop server?
gmlee
03-26-2002, 01:20 PM
If your internet connection is up, you should be able to run the mail command without turning sendmail on.
Sendmail is an SMTP server. In most setups, you will use your ISP's SMTP server for outgoing email and POP/IMAP for incoming email. If you had a slow dial-up connection and wanted to limit your dial-ins, you might run sendmail to provide "store and forward" functionality (i.e., your local sendmail server would store outgoing mail until a connection was established).
GUI e-mail clients usually provide "store and forward" capabilities, a.k.a. offline mode or send mail later. The mail command doesn't, so you need to make there is something to recieve the email from the mail command -- either a local sendmail or your ISP's SMTP server. The latter requires an active internet connection, the former does not.
Hope this helps,
Gary.
mervTormel
03-26-2002, 01:49 PM
mail is just a user interface to the mail delivery agent, sendmail, which can be run as a daemon service
you don't need to do anything special, just address email to a valid email address and sendmail will deliver
% man sendmail
...
Sendmail is not intended as a user interface routine;
other programs provide user-friendly front ends; sendmail
is used only to deliver pre-formatted messages.
[and]
-bd Run as a daemon. This requires Berkeley IPC.
Sendmail will fork and run in background listening
on socket 25 for incoming SMTP connections. This
is normally run from /etc/rc.
...
here's a test. i don't have sendmail daemon running. i started a background top logger to capture sendmail in the act...
$ ps wwax | grep send
10369 std R+ 0:00.00 grep send
$ top -l100 > top.txt &
[1] 10065
$ mail -s "test" merv
test
.
EOT
$ %
top -l100 >top.txt
^C
$ grep send top.txt
10071 sendmail 0.0% 0:00.01 1 16 15 80K 364K 332K 1.46M
10073 sendmail 0.0% 0:00.02 1 9 18 356K 672K 520K 1.84M
exiting a mail message calls sendmail to do the dirty work.
sendmail will screech if any of the dirs in the chain /etc/mail are group writable, unless the
#O DontBlameSendmail=safe
is enabled in /etc/mail/sendmail.cf
macubergeek
03-26-2002, 01:54 PM
Ok
I tried mail command as my usual user id:
and got:
jamesk @ /Users/jamesk@HOME-->/etc/mail/sendmail.cf: line 81: fileclass: cannot open /etc/mail/local-host-names: Group writable directory
the perms on /etc/mail/local-host-names are:
-r--r--r-- 1 root wheel 0 Sep 2 2001 /etc/mail/local-host-names
so then I tried to do it as root:
root @ /Users/jamesk @home-->/etc/mail/sendmail.cf: line 81: fileclass: cannot open /etc/mail/local-host-names: Group writable directory
somehow I suspect that the perms on /etc/mail/local-host-names still ain't right:
btw the line in sendmail.cf the error refers to is:
Cwlocalhost
# file containing names of hosts for which we receive email
Fw/etc/mail/local-host-names
mervTormel
03-26-2002, 02:04 PM
here's an authoratative post on the sendmail gak...
http://forums.macosxhints.com/showthread.php?s=&threadid=1467
the root dir / is group-write enabled. removing that will make your mailman less disgruntled. note that the first thing that every apple software update does is chmod 1775 / so you have to add that notion to your administration. *sigh*
macubergeek
03-26-2002, 02:45 PM
sendmail will screech if any of the dirs in the chain /etc/mail are group writable, unless the
#O DontBlameSendmail=safe
is enabled in /etc/mail/sendmail.cf
merv...I don't know all the particulars but I was advised strongly not to do this....it leaves the system vulnerable....will try to find out why and post what I find.
jim
WillyT
03-26-2002, 08:52 PM
My isp blocks all outgoing mail unless it is sent through their smtp, or hotmail, or webmail. Something about spam. So how do we tell sendmail how to route to that?
macubergeek
03-27-2002, 04:16 AM
Yeh that's called port 25 filtering and it is due to spam and is an attempt on the part of isp's to come to grips with the problem. I believe you can just aim your box at one of their smtp servers via sendmail.cf but I must admit I'm not a sendmail guru. Maybe someone else has the exact config.
gmlee
03-28-2002, 09:52 AM
I believe you want to define your "smart relay host" via the DS macro. I haven't verified this as I have never looked at the sendmail.cf on the mac. Here's an example.
# replace smtp.isp.com with your ISP's smtp server name.
DSsmtp.isp.com
This tells sendmail to relay all non-local outgoing mail through the specified SMTP server.
Just search for "DS" in your sendmail.cf file. It should be documented within the file.
Hope this helps,
Gary.
macubergeek
03-28-2002, 09:57 AM
DSsmtp.isp.com
how do you determine the hostname here? Do you call up your isp and ask for their "smart" relay smtp server?
jk
gmlee
03-28-2002, 11:42 AM
I'm not sure where the confusion is?
You asked:
how do you determine the hostname here?
Yet my reply was was in response to your statement:
I believe you can just aim your box at one of their smtp servers via sendmail.cf but I must admit I'm not a sendmail guru. Maybe someone else has the exact config.
You can aim your box at your ISP's smtp server by using the DS macro in the sendmail.cf file. "Smart Relay" is just sendmail speak for "outgoing mail server". It's the same hostname you would specify in your mail client (Mail app, Outlook, etc.) as your outgoing mail server.
Example, I use Bakersfield Road Runner as my ISP. When I signed up, they gave me the following information.
Incoming mail server: pop-server.bak.rr.com
Outgoing mail server: smtp-server.bak.rr.com
If I wanted to send via the unix mail command, I would make sure that my sendmail.cf file had a line that looked like this:
DSsmtp-server.bak.rr.com
Note, no spaces between "DS" and the hostname, and DS must be the first two characters on the line (no white space!!!).
Clear as mud?!?
Gary
macubergeek
03-28-2002, 03:32 PM
sorry
just got lost in a bit of a sendmail speak circle. Thanks I'm clear now.
jim
z3eed
02-09-2005, 06:57 AM
I have some kind of problem that I cant solve..
My webbsite on my linux machine worked perfectly after I had configured my website.
After a reboot the mail() function stopped working.
Sendmail works perfectly.
If I look insida the maillog I can see that mail() triggers sendmail but it doesnt insert the correct information like where to send the mail.
I have tried this:
mail("me@mymail.com", "subject", "message", "From: myself");
And I get this in the log:
Feb 9 12:31:01 server sendmail[16975]: j19BV1v9016975: from=nobody, size=42, class=0, nrcpts=0, msgid=<200502091131.j19BV1v9016975@server.host.com>, relay=nobody@localhost
When I use the Sendmail application directly I get a better log.
Anyone that could help me?
// z3eed
Craig R. Arko
02-09-2005, 07:06 AM
I have some kind of problem that I cant solve..
My webbsite on my linux machine worked perfectly after I had configured my website.
After a reboot the mail() function stopped working.
...
Anyone that could help me?
// z3eed
You might want to look for a newsgroup or help site that's related to whatever Linux distribution you're using. Although I don't doubt there are folks here with considerable Linux expertise this is still really a Mac OS X related site.
Best of luck! :)
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.