PDA

View Full Version : [SOLVED] Email sent with mail command find, but no mail ever received



ebsco
13th October 2017, 10:03 AM
I have tried to send email using mail, subject and content , i sent the email mostly to myself.
I was using VirtualBox with Fedora as guest.



[MyUserName1@localhost ~]$ mail -s "some mail" MyUserName1
hi there
.


When i chaecked my mail : there was always no mail:


[MyUserName1@localhost ~]$ mail
no mail for MyUserName1


I replaced MyUserName1 with MyUserName1@localhost, and also with MyUserName1@localhost.localdomain, which is my localdomain in VirtualBox.
in var/mail/MyUserName1, or /var/spool/MyUserName1 , using cat command displayed nothing.

I even used mutt, the message was sent successfully but there is no mail when i checked.
Is there anything i am missing here?!

ocratato
13th October 2017, 10:47 AM
Its my (admittedly vague) understanding that the mail command is just the client side program. You would also need a server, such as sendmail or similar to route mail on the local machine. I don't believe such programs are started by default in many distributions as most people just use their ISP's server.

ebsco
13th October 2017, 12:22 PM
Thank for the reply.
In my host Ubuntu, mail works for sending mails to local users out of the box. In using mail command, there is no requirement to anything for it to work rather than installing it, if it is not installed by default.

Going back to Fedora, after installing ,restarting and logging in as root:



[root@localhost ~]# sendmail -s "Hello letter" MyUserName1@localhost.localdomain
hello there
.
[root@localhost ~]# exit
[MyUserName1 ~]$ mail
no mail for MyUserName1


Notice that i am using sendmail instead.

But here is another try with a message with command mail and the option -v , for verbose, i got this following :


MyUserName1 ~]$ mail -v -s "Hello letter" MyUserName1
Hello
.
EOT
MyUserName1... Connecting to [127.0.0.1] via relay...
MyUserName1... Deferred: Connection refused by [127.0.0.1]


I wish this helps on identifiying why mail command is not working.

ocratato
13th October 2017, 01:03 PM
Ubuntu probably starts a local email server by default, which is why it works.

The connection refused is a good indication that no mail server is running.
Your sendmail command used sendmail as a client - there still needs to be a server running (basically so that it can move files from one owner to another).

You can check if a server is running with


ss -l | grep smtp



I am not running Fedora, so I cannot say what the correct mail server is, and hence how to start it.
Can someone else advise ?

ebsco
13th October 2017, 02:03 PM
Ubuntu probably starts a local email server by default, which is why it works.

The connection refused is a good indication that no mail server is running.
Your sendmail command used sendmail as a client - there still needs to be a server running (basically so that it can move files from one owner to another).

You can check if a server is running with


ss -l | grep smtp



I am not running Fedora, so I cannot say what the correct mail server is, and hence how to start it.
Can someone else advise ?
You are definitely right!
I got nothing no output from running your command , and yes, fedora sendmail seems to use SMTP (Simple Mail Transfer Protocol), I got some help from this fedora guide (https://docs.fedoraproject.org/f26/system-administrators-guide/servers/Mail_Servers.html).
Sendmail sendmail-cf configuration package need to be installed, i have to :

~]# dnf install sendmail-cf
generate new comfiguration:

~]# make all -C /etc/mail/
Also this has to be done:


~]# cd /etc/mail/
~]# make all

An d then restart service:


~]# systemctl restart sendmail


Sending mail now work perfectly.

I am surprised at the amount of detail and simplicity the Fedoraproject's guides are written , i am not used to that at all!!!

HaydnH
13th October 2017, 02:07 PM
There's too many things to write in a brief post here, please reference the admin guide which will tell you how to install sendmail, sendmail-cf and configure it all:

https://docs-old.fedoraproject.org/en-US/Fedora/26/html/System_Administrators_Guide/s2-email-mta-sendmail.html

ebsco
13th October 2017, 02:14 PM
There's too many things to write in a brief post here, please reference the admin guide which will tell you how to install sendmail, sendmail-cf and configure it all:

https://docs-old.fedoraproject.org/en-US/Fedora/26/html/System_Administrators_Guide/s2-email-mta-sendmail.html

That kind of detail in that documentation is indeed staggering to me!
Thank you for your replay!:)