LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Mail Command Failure driving me crazy (https://www.linuxquestions.org/questions/linux-newbie-8/mail-command-failure-driving-me-crazy-4175556945/)

sleftar 10-23-2015 02:46 AM

Mail Command Failure driving me crazy
 
Hi. I am looking how to use mail command, found some pages and tried to install mailutils and after that used the option, no configuration..

sudo apt-get install mailutils

whatever i did, ended up with a failure message such as:

Code:

ginger@multilayer:~$ mail -s "hello world" mygmail@gmail.com < letter.txt
mail: cannot send message: Process exited with a non-zero status

Is it due to my firewall settings? It is like this.

Quote:

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To Action From
-- ------ ----
22 ALLOW IN Anywhere
21/tcp ALLOW IN Anywhere
10999 ALLOW IN Anywhere
11001 ALLOW IN Anywhere
22 (v6) ALLOW IN Anywhere (v6)
21/tcp (v6) ALLOW IN Anywhere (v6)
10999 (v6) ALLOW IN Anywhere (v6)
11001 (v6) ALLOW IN Anywhere (v6)

Any help would be appreciated..

chrism01 10-23-2015 03:20 AM

mail (aka mailx) is just the end user util; it actually needs an MTA ie mail server SW eg sendmail, postfix etc) to send mail via.

What distro & version have you got? Do you have an MTA service installed; iif so check the logs or try eg /var/log/messages.
You could also try re-running with the '-v' option to get more info.

sleftar 10-23-2015 03:28 AM

ubuntu 14 server edition. I only installed mailutils.

http://www.binarytides.com/linux-mail-command-examples/

used this page and some others but did not work

chrism01 10-23-2015 03:36 AM

Like I said, you need an MTA aka mail server service.
According to a quick google, it looks like it would be postfix, so install it
Code:

sudo apt-get install postfix
I don't know if the default install will let you send emails; it probably will, but you need to google it eg log file locations etc.

sleftar 10-23-2015 03:39 AM

yeah i know, i also installed postfix.. gives same error

Quote:

ginger@multilayer:~$ mail -s "hello world" mygmail@gmail.com < letter.txt
mail: cannot send message: Process exited with a non-zero status

chrism01 10-23-2015 03:56 AM

Like I said, use the -v switch AND check all the logfiles - check with google for the exact log to look at.
For postfix its likely /var/log/maillog

sleftar 10-23-2015 04:01 AM

I dont think i really understand what i should do
what is -v switch?
there is no such a file /var/log/mailllog

Quote:

gingercook@DSTmultilayer:~$ cat var/log/maillog
cat: var/log/maillog: No such file or directory

sleftar 10-23-2015 04:11 AM

http://jafty.com/blog/tag/use-linux-...ils-from-shell
This link says log file is inside

/var/spool/mail/root

there is a path like
/var/spool/mail
but inside this directory there is no such a file named root or ec2-user.. Inside this directory is empty.

sleftar 10-23-2015 05:52 AM

Alright. I found the log file for this problem
It is inside the /var/log/mail.err

here is the log file

Quote:

Oct 23 02:05:32 DSTmultilayer postfix/sendmail[15605]: fatal: open /etc/postfix/main.cf: No such file or directory
Oct 23 02:58:34 DSTmultilayer postfix/sendmail[18817]: fatal: open /etc/postfix/main.cf: No such file or directory
Oct 23 03:02:29 DSTmultilayer postfix/sendmail[19057]: fatal: open /etc/postfix/main.cf: No such file or directory
Oct 23 03:08:45 DSTmultilayer sSMTP[19898]: Unable to locate mail
Oct 23 03:08:45 DSTmultilayer sSMTP[19898]: Cannot open mail:25
Oct 23 03:26:31 DSTmultilayer sSMTP[20969]: Unable to locate mail
Oct 23 03:26:31 DSTmultilayer sSMTP[20969]: Cannot open mail:25
Oct 23 03:29:37 DSTmultilayer sSMTP[21163]: Unable to locate mail
Oct 23 03:29:37 DSTmultilayer sSMTP[21163]: Cannot open mail:25
Oct 23 03:39:48 DSTmultilayer postfix/sendmail[22400]: fatal: open /etc/postfix/main.cf: No such file or directory
Oct 23 03:56:53 DSTmultilayer sSMTP[24021]: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 200sm6945666qhh.26 - gsmtp)
Oct 23 03:57:10 DSTmultilayer sSMTP[24045]: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 g77sm6997496qgd.5 - gsmtp)
Oct 23 04:36:03 DSTmultilayer postfix/sendmail[27194]: fatal: open /etc/postfix/main.cf: No such file or directory
Oct 23 04:36:30 DSTmultilayer postfix/sendmail[27620]: fatal: open /etc/postfix/main.cf: No such file or directory
Oct 23 04:38:46 DSTmultilayer postfix/sendmail[27755]: fatal: open /etc/postfix/main.cf: No such file or directory
Oct 23 05:06:05 DSTmultilayer postfix/sendmail[29345]: fatal: open /etc/postfix/main.cf: No such file or directory
Oct 23 05:08:22 DSTmultilayer postfix/sendmail[29479]: fatal: open /etc/postfix/main.cf: No such file or directory
Oct 23 06:48:44 DSTmultilayer postfix/sendmail[2976]: fatal: open /etc/postfix/main.cf: No such file or directory

Tonus 10-23-2015 06:08 AM

Mail Command Failure driving me crazy
 
Looks like you're missing the config file

Have a look here :
http://www.postfix.org/BASIC_CONFIGURATION_README.html

sleftar 10-23-2015 08:15 AM

seriously why it is missing? Should be there by default. And do I have to manually add all of these things? No other solution for this problem?

sleftar 10-23-2015 08:23 AM

ALright i just created an empty main.cf file and restarted postfix. It worked for some reason even though the main.cf is empty... Sends mails to my gmail but gmail thinks those are spam...

Tonus 10-23-2015 09:37 AM

Mail Command Failure driving me crazy
 
That might be fixed by adding yourself in some kind of white list or in Gmail address book I think...

sleftar 10-23-2015 10:01 AM

Quote:

Originally Posted by Tonus (Post 5439066)
That might be fixed by adding yourself in some kind of white list or in Gmail address book I think...

Thanks for the help :3


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