[SOLVED] Command Line Mail not working/sending, but no error?
Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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
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:
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...)
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:
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?
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:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.