LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-28-2021, 10:28 PM   #1
nikhilbirari
LQ Newbie
 
Registered: Jul 2021
Posts: 16

Rep: Reputation: Disabled
Question Unable to mail to self (on the same local machine)


Hello,

I am currently working on CentOS 7.2. I am trying to send email to myself on the same local machine. I get message as no mail for Nik (my username).

I have installed xmail
$ yum install xmail

and here is what I am entering in mail description

$ mail -s "Test mail" Nik < newfile

I have already created a newfile in my home directory. I am really not able to figure out what exactly is going wrong. Please assist me on the same
 
Old 07-29-2021, 07:06 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,631

Rep: Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696
xmail is, in general (the name has been used for other things) an email CLIENT. Are you running any email SERVER on your machine? (sendmail is the oldest, but there are a couple of dozen possible other choices) If you have nothing to RECEIVE the email, your SENDING the email would be EXPECTED to fail.

Generally, if you have an email server running it will be listening on port 25 for incoming connections. In secure mode, it will only listen in 127.0.0.1:25.
 
Old 07-29-2021, 11:41 AM   #3
nikhilbirari
LQ Newbie
 
Registered: Jul 2021
Posts: 16

Original Poster
Rep: Reputation: Disabled
I am not running any email server. How do I send email on the same local system. My trainer sent email to his local system in one of his videos (I am learning from pluralsight.com)

I am quite new to Linux so please reply in easy simple steps. Thanks in advance
 
Old 07-29-2021, 01:34 PM   #4
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
The simplest way I know on the local system is to use mail (default linux mail system)
"man mail" to see how it works and try it.
 
Old 07-29-2021, 11:49 PM   #5
nikhilbirari
LQ Newbie
 
Registered: Jul 2021
Posts: 16

Original Poster
Rep: Reputation: Disabled
man mail is helpful. Thanks. But still my problem is not solved.

Last edited by nikhilbirari; 07-30-2021 at 12:31 AM. Reason: -
 
Old 07-30-2021, 03:10 AM   #6
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by nikhilbirari View Post
I have installed xmail
$ yum install xmail
I'm pretty sure it was mailx, not xmail.

A standard CentOS 7 install should include the Postfix mail server:
Code:
rpm -q postfix

Last edited by shruggy; 07-30-2021 at 03:11 AM.
 
Old 07-30-2021, 04:31 AM   #7
nikhilbirari
LQ Newbie
 
Registered: Jul 2021
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
I'm pretty sure it was mailx, not xmail.

A standard CentOS 7 install should include the Postfix mail server:
Code:
rpm -q postfix

Yes mailx sorry. But still not working
 
Old 07-30-2021, 09:00 AM   #8
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,631

Rep: Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696
Quote:
Originally Posted by nikhilbirari View Post
Yes mailx sorry. But still not working
That is because, even for the local system, you need a mail SERVER to accept, process, and distribute the mail. If you do not have one installed and running, there is nothing to deliver that email. Try installing postfix.
 
Old 07-30-2021, 09:07 AM   #9
nikhilbirari
LQ Newbie
 
Registered: Jul 2021
Posts: 16

Original Poster
Rep: Reputation: Disabled
Package 2ostfix-2.10.1-9.el7.x86_64 already installed and latest version
Nothing to do

Postfix is already installed
 
Old 07-30-2021, 09:15 AM   #10
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,631

Rep: Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696
Quote:
Originally Posted by nikhilbirari View Post
Package 2ostfix-2.10.1-9.el7.x86_64 already installed and latest version
Nothing to do

Postfix is already installed
And is it running as a service? Is it listening on port 25?


Would you like some light reading in case it needs configuration? https://www.golinuxcloud.com/configu...tp-relay-rhel/
 
Old 07-30-2021, 10:12 AM   #11
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
On my system, as it has been for years, mail (also now known as mailx) is both the server and client. Since the early 90s have been able to send & receive mail on the local machine. The servers postfix or sendmail have only been needed when mail is sent outward or received inward from another host (LAN or internet)

This is my default, and I have never installed mail or mailx and have not installed nor configured sendmail nor postfix. Mail has always worked on the local machine.
Code:
# ls -l /usr/bin/mail*
lrwxrwxrwx. 1 root root     22 Dec 28  2020 /usr/bin/mail -> /etc/alternatives/mail
-rwxr-xr-x. 1 root root   2818 Jan 27  2021 /usr/bin/mailodf
lrwxrwxrwx. 1 root root     27 Mar 16 12:35 /usr/bin/mailq -> /etc/alternatives/mta-mailq
lrwxrwxrwx. 1 root root     23 Dec 28  2020 /usr/bin/mailx -> /etc/alternatives/mailx
-rwxr-xr-x. 1 root root 422912 Mar 16 14:02 /usr/bin/mailx.mailx
One thing that is certain with mail & mailx is that it can only work when sending/receiving mail from an existing user account on that machine or with a proper entry in /etc/aliases, while sendmail & postfix can send/receive mail for the domain, even if the user is not local on that server.
 
Old 07-30-2021, 07:29 PM   #12
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,631

Rep: Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696
Quote:
How does it work
The mail/mailx command needs a local smtp server (MTA) running in order to deliver the emails. THe route taken by the email is somewhat like this -
from https://www.binarytides.com/linux-mailx-command/

Searching, I found no examples of how to make mail, xmail, or mailx act like a MTA. It needs to communicate (SMTP, IMAP, or other mail protocol) to the MTA that acts as the server and delivery agent.

If anyone has a URL pointing to a documentation that shows how to make the CLIENT act like an MTA, please provide that so I can read through that documentation.
 
Old 07-30-2021, 09:58 PM   #13
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Read the man page for esmtprc. The config details are there.
 
Old 07-30-2021, 10:45 PM   #14
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,631

Rep: Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696
Quote:
Originally Posted by computersavvy View Post
Read the man page for esmtprc. The config details are there.
That is the man page for the configuration file for esmtp - libESMTP to Sendmail compatibility interface. That requires using SENDMAIL MTA.

That does not involve using mail, xmail, or mailx WITHOUT an MTA as both mail server (MTA) and client as described.

BTW your process list shows "mailq" running. Mailq is an MTA, a replacement for sendmail (and in some ways an improved MTA). In other words you were running an MTA serving your mail functions. Every time you send mail using mail, mailx, or xmail you are using the mail SERVER (mailq) to deliver or route that mail. It is the MTA that enables delivery from the email clients. (Although, the MTA CAN be running on a rmeote machine and serving and accepting email using SMTP, if your client understands smtp and either pop/pop3 or IMAP protocols.)

Which brings us back to this: to properly deliver local mail on his machine, the OP needs an MTA running. It should be listening to port 25 on at least one IP address on that machine, possibly the loopback address 127.0.0.1

Last edited by wpeckham; 07-30-2021 at 10:48 PM.
 
Old 07-31-2021, 02:17 AM   #15
nikhilbirari
LQ Newbie
 
Registered: Jul 2021
Posts: 16

Original Poster
Rep: Reputation: Disabled
I found this url https://bbs.archlinux.org/viewtopic.php?id=179366

In the last comment he is mentioned that he had wrongly configured MAIL variable in his bashrc

Anything to do with my issue?

Last edited by nikhilbirari; 07-31-2021 at 02:36 AM. Reason: -
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How does ignored self encryption work on self encrypting drive? rblampain Programming 1 12-15-2017 08:13 AM
Can two hosts in the same LAN have the same local hostname? stf92 Slackware 27 02-16-2013 03:15 AM
After ssh'ing to self machine, unable to display xclock??? Passions Linux - Software 4 02-25-2008 04:12 PM
prevent users to run the same script at the same time, on the same machine pvpnguyen Programming 2 09-05-2007 08:52 PM
Setup local machine to allow lan machines to retrieve its local user mail. Brian1 Linux - Networking 3 03-30-2006 05:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:34 PM.

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