LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 08-27-2013, 07:08 PM   #1
Jonnothin
LQ Newbie
 
Registered: Jun 2013
Posts: 8

Rep: Reputation: Disabled
Command Line Mail not working/sending, but no error?


Hi,
I've been trying to send a email through the cli in an opensuse box for about 45 minutes and for whatever reason it doesn't send anything. Here's the command I'm using:

Code:
mail -s "Hello World" myvalidemail@validdomain.com
This is a test
.
<EOT>
I thought that OpenSuSE was somehow misconfigured so I also tried this on a CentOS box and it doesn't work there either.

The question is what would prevent mail from working? As I understand it shouldn't it just work? or is there some kind of configuration I'm missing?
 
Old 08-27-2013, 07:29 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
There are no guarantees that mail will just work .. there are many issues that could be impacting you:

- MTA is not running
- MTA is not configured to forward non-local email
- MTA is not permitted to connect to Internet IP's on tcp/25 due to firewall
- MTA is required to forward to a relay but is not configured to

Depending on the MTA you have installed, it may or may not work out of the box in your environment. If you provide some more details and some info on your environment we should be able to assist
 
Old 08-27-2013, 07:32 PM   #3
Jonnothin
LQ Newbie
 
Registered: Jun 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
Clearly I don't know as much as I thought because I don't know what MTA is...

What do you need to know and where do I get it from?
 
Old 08-27-2013, 08:15 PM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
An (MTA) Mail Transfer Agent is used to transfer mail between different systems .. common MTA's being postfix, sendmail and exim. In your case to determine which one is in use:

Code:
rpm -qa | grep -e postfix -e sendmail -e exim
Once you have a match you can check whether it's running:

Code:
/etc/rc.d/init.d/{sendmail,postfix,exim} status
.. and then whether its listening on tcp/25:

Code:
sudo netstat -tnlp | grep :25
 
Old 08-28-2013, 12:44 PM   #5
Jonnothin
LQ Newbie
 
Registered: Jun 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
Here are the outputs of those commands:

Code:
linux-gola:/etc/nagios # rpm -qa | grep -e postfix -e sendmail -e exim
postfix-2.9.6-1.2.1.x86_64
Code:
linux-gola:/etc/nagios # /etc/rc.d/init.d/postfix status
bash: /etc/rc.d/init.d/postfix: No such file or directory
linux-gola:/etc/nagios # service postfix status
postfix.service - Postfix Mail Transport Agent
          Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled)
          Active: inactive (dead)
          CGroup: name=systemd:/system/postfix.service

Aug 27 08:54:19 linux-gola postfix/smtp[5870]: connect to alt1.aspmx.l.google.com[7...st
Aug 27 08:54:19 linux-gola postfix/smtp[5870]: connect to alt2.aspmx.l.google.com[1...st
Aug 27 08:54:19 linux-gola postfix/smtp[5870]: connect to aspmx3.googlemail.com[173...st
Aug 27 08:54:19 linux-gola postfix/smtp[5870]: connect to aspmx2.googlemail.com[74....st
Aug 27 08:54:19 linux-gola postfix/smtp[5870]: 3B8DC29B62: to=<jonathan.williams@ct...t)
Aug 27 08:56:14 linux-gola systemd[1]: Stopping Postfix Mail Transport Agent...
Aug 27 08:56:14 linux-gola postfix/postfix-script[7037]: stopping the Postfix mail s...m
Aug 27 08:56:14 linux-gola postfix/master[2317]: terminating on signal 15
Aug 27 08:56:14 linux-gola systemd[1]: Stopped Postfix Mail Transport Agent.
Aug 27 08:56:14 linux-gola systemd[1]: Stopped Postfix Mail Transport Agent
I tried starting it and it looks like it's working:
Code:
linux-gola:/etc/nagios # service postfix start
linux-gola:/etc/nagios # service postfix status
postfix.service - Postfix Mail Transport Agent
          Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled)
          Active: active (running) since Wed, 2013-08-28 03:32:35 PDT; 3s ago
         Process: 13670 ExecStartPost=/etc/postfix/system/cond_slp register (code=exited, status=0/SUCCESS)
         Process: 13668 ExecStartPost=/etc/postfix/system/wait_qmgr 60 (code=exited, status=0/SUCCESS)
         Process: 13597 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
         Process: 13594 ExecStartPre=/etc/postfix/system/update_postmaps (code=exited, status=0/SUCCESS)
         Process: 13590 ExecStartPre=/etc/postfix/system/update_chroot (code=exited, status=0/SUCCESS)
         Process: 13587 ExecStartPre=/etc/postfix/system/config_postfix (code=exited, status=0/SUCCESS)
         Process: 13583 ExecStartPre=/bin/echo Starting mail service (Postfix) (code=exited, status=0/SUCCESS)
        Main PID: 13667 (master)
          CGroup: name=systemd:/system/postfix.service
                  ├ 13667 /usr/lib/postfix/master
                  ├ 13677 pickup -l -t fifo -u
                  ├ 13678 qmgr -l -t fifo -u
                  ├ 13685 trivial-rewrite -n rewrite -t unix -u
                  ├ 13688 smtp -t unix -u
                  ├ 13689 smtp -t unix -u
                  ├ 13692 smtp -t unix -u
                  ├ 13693 smtp -t unix -u
                  ├ 13694 smtp -t unix -u
                  └ 13695 smtp -t unix -u

Aug 28 03:32:35 linux-gola postfix/qmgr[13678]: 474E829B73: from=<nagios@linux-gola....)
Aug 28 03:32:35 linux-gola postfix/qmgr[13678]: 40CAD29B3C: from=<nagios@linux-gola....)
Aug 28 03:32:35 linux-gola postfix/qmgr[13678]: 4357329B0B: from=<nagios@linux-gola....)
Aug 28 03:32:35 linux-gola postfix/qmgr[13678]: 3B8DC29B62: from=<root@linux-gola.si...)
Aug 28 03:32:35 linux-gola postfix/qmgr[13678]: 3FE5B29B53: from=<nagios@linux-gola....)
Aug 28 03:32:35 linux-gola postfix/qmgr[13678]: 3854A29ADE: from=<nagios@linux-gola....)
Aug 28 03:32:35 linux-gola postfix/qmgr[13678]: 3963029B77: from=<nagios@linux-gola....)
Aug 28 03:32:35 linux-gola postfix/qmgr[13678]: 2783129B48: from=<nagios@linux-gola....)
Aug 28 03:32:35 linux-gola postfix/qmgr[13678]: 2A3BA29AFF: from=<nagios@linux-gola....)
Aug 28 03:32:35 linux-gola postfix/qmgr[13678]: 063C029B7B: from=<root@linux-gola.si...)
Code:
linux-gola:/etc/nagios # netstat -tnlp |grep :25
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      13667/master 
ster
I then tried the mail command and still nothing so I'm assuming there's something wrong with the setup somehow.
 
Old 08-28-2013, 05:58 PM   #6
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Ok, so now we know that you're using postfix

Quote:
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled)
It should have been running, so maybe it died or was stopped for some reason. Could you run the following command and post the output after attempting to send another test email:

Code:
tailf /var/log/maillog
 
Old 08-28-2013, 06:13 PM   #7
Jonnothin
LQ Newbie
 
Registered: Jun 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
tailf /var/log/maillog

It says that maillog doesn't exist. An "ls /var/log" confirms this. Also, while trying to figure this out (I should have mentioned this earlier) I uninstalled postfix and installed sendmail, but then after it didn't work uninstalled sendmail and reinstalled postfix. Would that remove the log? Or is the log somewhere else? Also this system doesn't get restarted very often (it's a VM). Should I restart?
 
Old 08-28-2013, 06:33 PM   #8
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
/var/log/maillog is managed by your syslog server, please check for /etc/syslog.conf or /etc/rsyslog.conf, you should have a line something like:

Code:
# Log all the mail messages in one place.
mail.*                                                  -/var/log/maillog
 
Old 08-29-2013, 07:29 PM   #9
Jonnothin
LQ Newbie
 
Registered: Jun 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
Would these errors have something to do with it? or should I get the whole file?

2013-08-29T10:22:40.331469-07:00 linux-gola postfix/error[2338]: 238AA29B6C: to=<it@ctillc.com>, relay=none, delay=80375, delays=80374/1.4/0/0.13, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to aspmx3.googlemail.com[74.125.130.27]:25: No route to host)
 
Old 08-29-2013, 08:02 PM   #10
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Yep, looks like now you need to resolve the connectivity issue - you're making progress

Can you tell us anything about your network architecture? .. is the host you're on behind a firewall?

Just to confirm please try:
Code:
$ telnet 74.125.130.27 25
Trying 74.125.130.27...
Connected to 74.125.130.27.
Escape character is '^]'.
220 mx.google.com ESMTP n22si2660753yha.289 - gsmtp
If you don't see the last 3 lines above then you probably have a firewall between you and the internet which is blocking outbound email. If this is a corporate network then it's possible that there is a mail relay configured, you may need to request relay permission or justify direct outbound connections.

To configure postfix to relay all outbound email just run:
Code:
postconf -e "relayhost = [<fqdn_of_mail_relay>]"
 
Old 08-30-2013, 05:40 AM   #11
Jonnothin
LQ Newbie
 
Registered: Jun 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
This is behind a corporate network, so I'll see what I can find out. I believe we are behind at least 1 firewall, and a content filter.
 
Old 09-04-2013, 06:52 AM   #12
Jonnothin
LQ Newbie
 
Registered: Jun 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
It works! I just needed the correct domain name for the email server. The firewall wasn't the issue.

Thanks for all your help!
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending mail from command line. alaios Linux - Software 8 03-07-2013 09:15 AM
Command line e-mail and NOT sending out malware nelson202tx Linux - Newbie 2 10-16-2010 02:36 AM
Sending mail from command line Geert86 Linux - Server 10 11-30-2009 12:04 PM
Sending mail from command line matiasquestions Linux - Software 5 01-22-2006 11:51 AM
sending mail from command line won't work disorderly Linux - General 2 06-09-2005 11:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:52 AM.

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