Unable to mail to self (on the same local machine)
Linux - NewbieThis 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
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.
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.
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
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.
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.
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 -
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.