LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-14-2006, 04:23 PM   #1
Madone_SL_5.5
Member
 
Registered: Oct 2006
Location: Ogden, Utah
Distribution: Fedora 10
Posts: 66

Rep: Reputation: 15
Cannot send email using "mail" command.


I am using Fedora Core 6 and trying to test the "mail" command.

I enter a command such as the following:

Code:
# mail somebody@somedomain.com
Subject: Test email
This is a test.
CC:
I get no errors or any feedback (no news is good news, right?), but the e-mail never arrives at the other end.

I have sendmail configured correctly (to my knowledge). Do I even need sendmail to send my e-mail? I have been told that I don't even need sendmail if I only intend to send email and not receive. I intend only to set it upo so that php scripts can send mail from my website.

Where do I begin? I'm by no means an expert, so any help would be greatly appreciated.

Thanks.
 
Old 11-14-2006, 05:40 PM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
Is sendmail running? You do need some type of MTA to send the message. Where are you sending the message to? If your on a DHCP system from your ISP sending to an ISP or account like Hotmail or the like, they could be dropping the email thinking its coming from a spammer since your on a DHCP enabled connection.
 
Old 11-14-2006, 06:12 PM   #3
Madone_SL_5.5
Member
 
Registered: Oct 2006
Location: Ogden, Utah
Distribution: Fedora 10
Posts: 66

Original Poster
Rep: Reputation: 15
Sendmail is running. I am sending the message to my personal account @juno.com (not on my network, of course).

I am not using DHCP. I have a static IP issued by my ISP Qwest.net.

Last edited by Madone_SL_5.5; 11-14-2006 at 06:13 PM.
 
Old 11-14-2006, 06:41 PM   #4
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 1,979

Rep: Reputation: 290Reputation: 290Reputation: 290
You need a mail transport agent (MTA) installed and configured, but it does not have to be running as a daemon to send mail. It's actually a good idea NOT to have it runing as a daemon (for security reasons), unless you have some requirement.

Your MTA may be sendmail, or it may be exim4. There could be others that I'm not aware of.

If it's exim4, then it's logs might be in /var/log/exim4/mainlog. That's where they are on my (Debian) system. You may find some errors in that file. Or possibly you'll find stuff in /var/log/mail.err (or mail.warn, or mail.info, etc.) Depends on how your syslog is configured.

You also need to configure you MTA to know where your SMTP server is, otherwise it doesn't know where to send the mail! On my system, this appears to be done in the file /etc/exim4/update-exim4.conf.conf. I have no idea how the Debian maintainers came up with that particular filename, but that's where the config appears to be. Inside that file is the line "dc_smarthost='smtp.earthlink.net'" I don't remember exactly how I configured exim4, it was probably when I first installed Debian a long time ago. I do know that I do not have the daemon running,because I manually did away with it in the system startup scripts (found in /etc/rc3.d, etc.)

You might not even have an MTA installed, although I'll bet you do by default (but I'm not familiar with Fedora). You should be able to check, something like this:
Code:
# whereis sendmail
sendmail: /usr/sbin/sendmail /usr/lib/sendmail /usr/share/man/man8/sendmail.8.gz
# ls -l /usr/sbin/sendmail
lrwxrwxrwx 1 root root 5 2005-12-30 11:01 /usr/sbin/sendmail -> exim4
# ls -l /usr/lib/sendmail
lrwxrwxrwx 1 root root 13 2005-12-30 11:01 /usr/lib/sendmail -> ../sbin/exim4
# ls -l /usr/sbin/exim4
-rwsr-xr-x 1 root root 656588 2005-11-28 11:19 /usr/sbin/exim4
#
 
Old 11-17-2006, 03:31 PM   #5
Madone_SL_5.5
Member
 
Registered: Oct 2006
Location: Ogden, Utah
Distribution: Fedora 10
Posts: 66

Original Poster
Rep: Reputation: 15
Thanks for your help. Sorry to take so long to respond. I am mainly a website designer, so I have been working out bugs in code for a few days and haven't had much time to devote to the mail issue.

In searching around, I found a bunch of errors in /var/log/mailllog (probably as many as I have made attempts).

This is an example of one of those errors:

Quote:
Nov 12 06:01:53 server sm-msp-queue[10928]: kA8Mhpfn007494: to=michaeljohnellis@juno.com, ctladdr=apache (48/48), delay=3+14:18:02, xdelay=00:00:00, mailer=relay, pri=7860084, relay=[127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
There are also errors of the same type addressed to "postmaster", "apache", and "root", among others. I'm not sure how those get generated, but they are all the same error as above.

Now, as far as I can tell, this means that the localhost is refusing to send the mail, right?

What does that indicate?

Last edited by Madone_SL_5.5; 11-17-2006 at 03:34 PM.
 
Old 11-17-2006, 08:12 PM   #6
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 1,979

Rep: Reputation: 290Reputation: 290Reputation: 290
Quote:
Now, as far as I can tell, this means that the localhost is refusing to send the mail, right?
This is not sendmail telling you it's refusing to send the mail. "Connection refused" is a standard message you get from the OS whenever you try to access a closed port (service may not be running, or you could be hitting a firewall).

It looks like your have things configured to connect to localhost to send outgoing mail. For this to work, you must have a sendmail daemon listening on port 25. You can check if you do like this: netstat -an | grep LISTEN | grep 25 Do you have a process listening on port 25? If you do, you could also have a firewall configured (misconfigured?) to block access to port 25 from localhost.

I am not a sendmail expert. Not even a neophyte either, when it comes to configuring it. But I do know, that for outgoing mail only, you do not need to have the port 25 listener (the daemon) running. Except if you have other configuration (or applications) that expects it to be running.

Instead of calling mail, why don't you call sendmail directly? It's simpler, and safer.
Code:
cat message | /usr/lib/sendmail -t
The file "message" that you are cat'ing to sendmail must contain the "To: " line of recipients.

This is safer because sendmail reads the recipients from the message file, so people can't play tricks as easy as with the mail command.

You can see this coding security hole with a website example. Lots of people ask for a recipient email address on their website and then do something like system("cat file_to_send | mail user@domain.com"). The end user specified "user@domain.com" in a form on your website. But what if this user had entered their email address as gotcha; rm -rf * Your resulting email command would then have been:
Code:
cat file_to_send | mail gotcha; rm -rf *
Think about that for a moment. Besides being destructive like the above, a hacker could use this to inspect your system from the inside. Not a good security scenerio.

If you use sendmail ( with -t ) directly, it reads the recipient from the cat'ed fail and thus semicolons and other shell special characters are meaningless. Sendmail has enough security holes in it's history. You don't need to add more by using mail just to access sendmail.

Besides, if you abandon mail and go for direct sendmail, your problem of "Connection refused" might just dissappear. Maybe, maybe not - but it doesn't hurt to try the simple things first.
 
Old 11-18-2006, 03:22 PM   #7
Madone_SL_5.5
Member
 
Registered: Oct 2006
Location: Ogden, Utah
Distribution: Fedora 10
Posts: 66

Original Poster
Rep: Reputation: 15
Thanks for the ideas. The server is listening on port 25. The command you gave me did not work with sendmail, so I just gave up on sendmail and switched to exim, after reading a little about it on its website.

I then used the command:

Code:
cat message | /usr/lib/sendmail.exim -t
and received an email instantly.

I suppose I have sendmail configured incorrectly. It is a fairly difficult program to configure.

Thanks again for your help. I'll just be happy to use exim from now on. That's fine.
 
  


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
Shel script mail send ("/" in mail address) problem anaid Linux - Networking 3 08-23-2005 07:41 AM
Unable to send email "Relaying denied" ejain Linux - Software 3 05-30-2005 09:31 AM
Unable to send email "Relaying denied" ejain Linux - Software 2 05-21-2005 08:02 AM
How to send email with attachment using "mail"? jonathanztaub Linux - Software 4 05-10-2004 11:53 AM
How to have vsftpd ask for anon user to "send email for password"? dmurray8888 Linux - Software 0 04-27-2004 03:08 PM


All times are GMT -5. The time now is 06:11 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