LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-07-2018, 06:27 PM   #1
sysmicuser
Member
 
Registered: Mar 2010
Posts: 423

Rep: Reputation: 0
Unhappy Unable to send email from CentOS machine


Can I seek your assistance to see how can I use mailx or mail on my CentOS 7.5?

I was able to send emails before but now I am not.

Is there any config file where I need to input the mail server settings?

Some configuration from the CentOS server is as below

Code:
[jim@centos74.master /data/OnlyOnMyPC/ansible]nmap localhost | grep -i smtp
25/tcp   open  smtp
[jim@centos74.master /data/OnlyOnMyPC/ansible]nmap centos74.master | grep -i smtp
[jim@centos74.master /data/OnlyOnMyPC/ansible]cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[jim@centos74.master /data/OnlyOnMyPC/ansible]hostname
centos74.master
[jim@centos74.master /data/OnlyOnMyPC/ansible]ps -ef|grep -i mail
jim      28723  4607  0 11:24 pts/0    00:00:00 grep --color=auto -i mail
[jim@centos74.master /data/OnlyOnMyPC/ansible]ps -ef|grep -i mail|grep -v grep
[jim@centos74.master /data/OnlyOnMyPC/ansible]

[jim@centos74.master /data/OnlyOnMyPC/ansible]telnet x.y.com.au 25
Trying [IP Address ] ...
Connected to x.y.com.au.
Escape character is '^]'.
220 x.y.com.au
quit
221 Service closing transmission channel
Connection closed by foreign host.
[jim@centos74.master /data/OnlyOnMyPC/ansible]

I could telnet from VM to SMTP server on port 25.

Appreciate your assistance in advance

Thanks
 
Old 11-07-2018, 07:34 PM   #2
ShadowCat8
Member
 
Registered: Nov 2004
Location: San Bernardino, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 258

Rep: Reputation: 52
Greetings,

Well, if you are using mailx, then you should have a config file for it to read... usually ~/.mailrc

And, from the man page on how to create the settings for an account:
Quote:
Originally Posted by man mailx
account
(ac) Creates, selects or lists an email account. An account is formed by a group of commands, primarily of those to set variables. With two arguments, of which the second is a `{', the first argument gives an account name, and the following lines create a group of commands for that account until a line containing a single `}' appears. With one argument, the previously created group of commands for the account name is executed, and a folder command is executed for the system mailbox or inbox of that account. Without arguments, the list of accounts and their contents are printed. As an example,
Code:
                  account myisp {
                      set folder=imaps://mylogin@imap.myisp.example
                      set record=+Sent
                      set from="myname@myisp.example (My Name)"
                      set smtp=smtp.myisp.example
                  }
creates an account named `myisp' which can later be selected by specifying `account myisp'.
Hope that helps. Let us know.
 
Old 11-07-2018, 09:35 PM   #3
sysmicuser
Member
 
Registered: Mar 2010
Posts: 423

Original Poster
Rep: Reputation: 0
Unhappy

It appears that my initial command might have been mail instead of mailx:

Code:
[root@centos74.master ~]find / -xdev -type f -name "mailrc"
[root@centos74.master ~]find / -xdev -type f -name ".mailrc"
The above indicates that I do not have .mailrc, is there any global configuration file/settings?
 
Old 11-08-2018, 06:05 AM   #4
dc.901
Member
 
Registered: Aug 2018
Location: Atlanta, GA - USA
Distribution: CentOS/RHEL, openSuSE/SLES, Ubuntu
Posts: 775

Rep: Reputation: 241Reputation: 241Reputation: 241
What happens if you use mail? Here is an example:

Code:
echo "Test email from CentOS - body" | mail -s "mail subject" -r replytoemail@mydomain.com <your email address here>
 
Old 11-08-2018, 08:54 AM   #5
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.8.2003
Posts: 4,835

Rep: Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765
What has changed since you were able to send mail?
 
Old 11-12-2018, 10:10 PM   #6
sysmicuser
Member
 
Registered: Mar 2010
Posts: 423

Original Poster
Rep: Reputation: 0
@dc.901 No success. I know the problem but I don't know the solution. Somehow emails are going through cloud mail server (Office 365) instead of the internal mail server. I don't know what that is happening but I can clearly see it happening.
 
Old 11-12-2018, 11:57 PM   #7
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.8.2003
Posts: 4,835

Rep: Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765
What is the internal mail server? Sendmail, postfix, qmail...?
 
Old 11-13-2018, 05:32 PM   #8
sysmicuser
Member
 
Registered: Mar 2010
Posts: 423

Original Poster
Rep: Reputation: 0
@scasey, the Internal mail server is a product as a Service from https://www.smartertools.com/

I'm just advised that there is an authentication on the internal mail server and they have created a service account for me. How should I use it? I don't know much about it.
 
Old 11-13-2018, 06:26 PM   #9
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.8.2003
Posts: 4,835

Rep: Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765Reputation: 1765
Quote:
Originally Posted by sysmicuser View Post
@scasey, the Internal mail server is a product as a Service from https://www.smartertools.com/

I'm just advised that there is an authentication on the internal mail server and they have created a service account for me. How should I use it? I don't know much about it.
Have you reviewed their documentation and/or asked them for support?
I don't know anything about it or how to use it, but there looks to be pretty good documentation on that site.
 
Old 11-13-2018, 06:56 PM   #10
sysmicuser
Member
 
Registered: Mar 2010
Posts: 423

Original Poster
Rep: Reputation: 0
@scasey, Thanks for that, I can figure that out, my concern is how to tell CentOS not to use O365 but to use the internal mail server. How to configure that. There must be some settings for that?
 
Old 11-13-2018, 07:04 PM   #11
sysmicuser
Member
 
Registered: Mar 2010
Posts: 423

Original Poster
Rep: Reputation: 0
An interesting thing is another Centos machine is sending email correct, although they are being received in Junk folder, but at least its working.
 
Old 11-14-2018, 09:16 PM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,774

Rep: Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537Reputation: 2537
Have you looked at /var/log/maillog ?
On your system, if its RHEL/Centos 6 or 7, it defaults to installing postfix mailserver service (smtp).

You use mailx to send to another serve, but it has to go through a local smtp eg postfix - hence the log.
 
Old 11-15-2018, 06:19 AM   #13
dc.901
Member
 
Registered: Aug 2018
Location: Atlanta, GA - USA
Distribution: CentOS/RHEL, openSuSE/SLES, Ubuntu
Posts: 775

Rep: Reputation: 241Reputation: 241Reputation: 241
Quote:
Originally Posted by sysmicuser View Post
An interesting thing is another Centos machine is sending email correct, although they are being received in Junk folder, but at least its working.
Is this another Centos machine also in DMZ network? And how exactly are you sending emails from this another server (mail command, telnet, or your application)?
As chrism01 mentioned, review your logs to see what's happening.
After you send emails from both servers, what is output of mailq command?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] [Email] Can not send email from a LINUX machine thomas2004ch Linux - Software 1 03-26-2015 05:53 AM
sendmail is unable to get access to the outside world? unable to send email? cyberdome Linux - Server 25 04-02-2014 10:40 AM
Unable to send email with sendmail from PHP 5.3 on CentOS VM crmpicco Linux - Newbie 1 02-14-2014 07:42 AM
How can i get unix to send an email to windows machine Nejad Linux - Server 1 12-03-2007 11:34 PM
Can't send email from my machine to internet BrianK Linux - Networking 3 02-10-2006 09:02 PM

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

All times are GMT -5. The time now is 01:28 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration