• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 655
  • Last Modified:

Recieve Email from outside to linux

I need the easiest solution possible. I do not need a complex setup or even the ability to send mails.

I need a way to receive email into my linux machine. so say its if from outlook I sent to


I want to recieve it into my shell.

I tried configuring postfix but no luck, I have never done this and the tutorials are not helping.

Could someone please be kind enough to walk me through this? Thanks
  • 6
  • 4
1 Solution
I dont use postfix

but if  you want, i can help you with sendmail

its easy and straight forward

yum install sendmail

after install it

go to

cd /etc/mail
vi sendmail.mc

look for this line

DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')dnl

and make it like this

DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl

now Save the file

now restart sendmail

service sendmail restart

now if you sent email like this

TO : root@ip-of-your mail server

you will received the email , if not then you have to use a domain name ( but i am sure without domain name you will be able to sendmail to this server)

also make sure , from your pc, you can telnet to the server like this

telnet ip-of-your-server 25

if its connected that means your server is ready to received email

to allow other user to received email you need to add them in /etc/aliases file

but i never tryed without domain, but it should work, let me know

Will need to cange the following line in the conf file to accept email:

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain  Could add the IP address to this line also.
mynetworks = 192.xxx.xxx.0/24,  (change to your localnetwork
myorigin = $mydomain
mydomain = <your domain>.com  

Also, if you are running a firewall (service iptables status), you will need to run this command to allow port 25:

iptables -I RH-Firewall-1-INPUT 6 -m state --state new -m tcp -ptcp --dport 25 -j ACCEPT

service iptables save
GTsafasAuthor Commented:

No luck, I cannot get to port 25

what is sendmail-cf?

Shutting down sm-client:                                   [  OK  ]
Shutting down sendmail:                                    [  OK  ]
Package sendmail-cf is required to update configuration.   [WARNING]
Starting sendmail:                                         [  OK  ]
Starting sm-client:                                        [  OK  ]


I tried everything there aside from the iptables command which returned the following

# iptables -I RH-Firewall-1-INPUT 6 -m state --state new -mtcp -ptcp --dport 25 -j ACCEPT
iptables v1.4.5: unknown protocol `-ptcp' specified

I modified it to

# iptables -A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 25 --syn -j ACCEPT

and recieved

iptables: No chain/target/match by that name
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

First off all
you cant use posfix and sendmail at the same time

so chose what  you want to run

No luck, I cannot get to port 25:
 if port 25 is not open then you can received email on the mail server

what is sendmail-cf? sendmail.cf is a file name it will be on /etc/mail directory

but you dont have this one

so donwload this  by

yum install sendmail-cf

it will install sendmail-cf packages


as the other Experts said, you need to look into iptables rules

whats the output of iptables ??

iptables -L    [ show the out put here ]

whats the output of your

cat /etc/sysconfig/iptables        ??

iptables rules could be 2 way : -A or -RH

so show the output of both iptables here
GTsafasAuthor Commented:
I have postfix disabled, here is my iptables output

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

cat /etc/sysconfig/iptables      is empty, I have firewall disabled btw so I dont think iptables matters.
GTsafasAuthor Commented:
so after i installed

yum install sendmail-cf

I am able to telnet on 25,

However when I send mail to my linux user @ ip I am not getting it.

I also cannot telnet to 110
I am able to telnet on 25 :  thats means its now working as mail server
However when I send mail to my linux user @ ip I am not getting it. :  this is i have little bit of doubt, i never tryed to mail an IP address.

Sent an email to your root@ip-of-server   ( not user@ip-of-server)

and look at log  /var/log/messages
 you can look at real time by this command

tail -f /var/log/messages

see if you see any entry or error after sending email to root@ip-of-server

can not you use a domain ??
i think root@ , will not work

you cant sent an email to an ip directly

have a look to this one




in google type : "sending email to an ip address"

you might have to use [ ] or ... i dont know i will try to find out
From linux to linux i can sent email like this

cat /etc/hosts | mail -s "test" root@[]

but i dont know about outlook , but try like this root@[]

also look at /var/log/maillog, see if you received any email or not


if you received any email, in command line , you should see something like , You have mail in /var/spool/mail/root

to check email for root : cat /var/spool/mail/root

GTsafasAuthor Commented:
I had to modify the config file to change every domain to my ip address.

Also had to run /etc/mail/make afterwards

Thanks so much
Good to see your problem solved

and sorry i forgot to say, you need to execute make command if you modify anything in sendmail.cf file

anyway. good luck

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now