Discussion:
specify SMTP relay server in mutt
Sunhux G
2014-07-15 16:35:19 UTC
Permalink
I have got the firewall rule permitted from our RHEL 5.x &
RHEL 6.x servers to our SMTP relay server (it's running
RHEL 5.8).

In the past, I recall I have a server that I could just issue
mutt command below & it will send email out via that
relay server :
mutt -s "Test mail" -a /tmp/file.tar.gz ***@nixcraft.co.in <
/tmp/mailmessage.txt


Now all my servers (at another site) can't send email out.
Did I need to set something at this site's server or is
there any way that I could specify the SMTP relay server
in the mutt command? In Windows, blat & sendemail
allows me to specify the SMTP relay server.

TIA
SH
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Fred Smith
2014-07-15 16:58:18 UTC
Permalink
Post by Sunhux G
I have got the firewall rule permitted from our RHEL 5.x &
RHEL 6.x servers to our SMTP relay server (it's running
RHEL 5.8).
In the past, I recall I have a server that I could just issue
mutt command below & it will send email out via that
/tmp/mailmessage.txt
Now all my servers (at another site) can't send email out.
Did I need to set something at this site's server or is
there any way that I could specify the SMTP relay server
in the mutt command? In Windows, blat & sendemail
allows me to specify the SMTP relay server.
Assuming you've got sendmail installed, and are using the default sendmail.cf,
become root, then:

cd /etc/mail
vi sendmail.cf

search for a line beginning with "DS", with a comment above it reading:
"Smart" relay host (may be null)
and change the line that reads just "DS" to read "DSyoursmarthost.foo"
or whatever the FQDN is of your smart relay host. there is NOT a space
between the "DS" and the FQDN.

you'll probably need to restart the sendmail service afterward.
--
---- Fred Smith -- ***@fcshome.stoneham.ma.us -----------------------------
Show me your ways, O LORD, teach me your paths;
Guide me in your truth and teach me,
for you are God my Savior,
And my hope is in you all day long.
-------------------------- Psalm 25:4-5 (NIV) --------------------------------
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Sunhux G
2014-07-16 02:00:37 UTC
Permalink
Thanks Fred.

Sendmail was listed by our audit as a non-secure
service. Must sendmail be started or is there any
other alternative to send email?

Think in Windows environment, blat & sendemail
doesn't require an equivalent service to work so
if there is some other ways of sending email, will
be great, say using telnet:

(does anyone has a script that could read in the
content of a text file, ie line 1-3 below & then
perform the steps below) :

# telnet SMTP_Relay_IP 25
HELO
501 Syntax: HELO hostname
HELO smtp.mypostfixdomain.com
250 hostname.mypostfixdomain.com
MAIL FROM:<***@external_domain.com.sg>
250 2.1.0 Ok
HELO smtp.mypostfixdomain.com
250 hostname.mypostfixdomain.com
MAIL FROM:<***@external_domain.com.sg>
250 2.1.0 Ok
RCPT TO:<***@mypostfixdomain.com>
250 2.1.5 Ok

RCPT TO:<***@mypostfixdomain.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
line 1
line 2
line 3
*.*
250 2.0.0 Ok: queued as BAF8A200034
Post by Fred Smith
Post by Sunhux G
I have got the firewall rule permitted from our RHEL 5.x &
RHEL 6.x servers to our SMTP relay server (it's running
RHEL 5.8).
In the past, I recall I have a server that I could just issue
mutt command below & it will send email out via that
/tmp/mailmessage.txt
Now all my servers (at another site) can't send email out.
Did I need to set something at this site's server or is
there any way that I could specify the SMTP relay server
in the mutt command? In Windows, blat & sendemail
allows me to specify the SMTP relay server.
Assuming you've got sendmail installed, and are using the default sendmail.cf,
cd /etc/mail
vi sendmail.cf
"Smart" relay host (may be null)
and change the line that reads just "DS" to read "DSyoursmarthost.foo"
or whatever the FQDN is of your smart relay host. there is NOT a space
between the "DS" and the FQDN.
you'll probably need to restart the sendmail service afterward.
--
-----------------------------
Show me your ways, O LORD, teach me your paths;
Guide me in your truth and teach me,
for you are God my Savior,
And my hope is in you all day long.
-------------------------- Psalm 25:4-5 (NIV)
--------------------------------
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Fred Smith
2014-07-16 02:26:27 UTC
Permalink
This post might be inappropriate. Click to display it.
Sunhux G
2014-07-16 02:47:37 UTC
Permalink
mutt & mailx are MUA (Message User Agent) while
postfix (& I think sendmail) have both MTA and MUA
functions (ie they can act as SMTP servers besides
as MUA).

I guess mailx will require sendmail.cf to be edited as
well: if only we have sort of script that does something
like the telnet & the series of HELO...DATA commands,
that will be wonderful (as I think it doesn't require an
MTA (eg: sendmail & postfix) to be running.

Correct me if my understanding is incorrect.


SH
Post by Fred Smith
Post by Sunhux G
Thanks Fred.
Sendmail was listed by our audit as a non-secure
service. Must sendmail be started or is there any
other alternative to send email?
there are other tools to do a similar job, but the only one
I've used, personally, is sendmail. I think Postfix is another
one that may be in Centos, though I have no experience with it.
Post by Sunhux G
Think in Windows environment, blat & sendemail
doesn't require an equivalent service to work so
if there is some other ways of sending email, will
(does anyone has a script that could read in the
content of a text file, ie line 1-3 below & then
# telnet SMTP_Relay_IP 25
HELO
501 Syntax: HELO hostname
HELO smtp.mypostfixdomain.com
250 hostname.mypostfixdomain.com
250 2.1.0 Ok
HELO smtp.mypostfixdomain.com
250 hostname.mypostfixdomain.com
250 2.1.0 Ok
250 2.1.5 Ok
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
line 1
line 2
line 3
*.*
250 2.0.0 Ok: queued as BAF8A200034
On Wed, Jul 16, 2014 at 12:58 AM, Fred Smith <
Post by Fred Smith
Post by Sunhux G
I have got the firewall rule permitted from our RHEL 5.x &
RHEL 6.x servers to our SMTP relay server (it's running
RHEL 5.8).
In the past, I recall I have a server that I could just issue
mutt command below & it will send email out via that
/tmp/mailmessage.txt
Now all my servers (at another site) can't send email out.
Did I need to set something at this site's server or is
there any way that I could specify the SMTP relay server
in the mutt command? In Windows, blat & sendemail
allows me to specify the SMTP relay server.
Assuming you've got sendmail installed, and are using the default sendmail.cf,
cd /etc/mail
vi sendmail.cf
"Smart" relay host (may be null)
and change the line that reads just "DS" to read "DSyoursmarthost.foo"
or whatever the FQDN is of your smart relay host. there is NOT a space
between the "DS" and the FQDN.
you'll probably need to restart the sendmail service afterward.
--
-----------------------------
Show me your ways, O LORD, teach me your paths;
Guide me in your truth and teach me,
for you are God my Savior,
And my hope is in you all day long.
-------------------------- Psalm 25:4-5 (NIV)
--------------------------------
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
-----------------------------
"For the word of God is living and active. Sharper than any double-edged
sword, it penetrates even to dividing soul and spirit, joints and marrow;
it judges the thoughts and attitudes of the heart."
---------------------------- Hebrews 4:12 (niv)
------------------------------
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Harris, Don
2014-07-16 03:12:12 UTC
Permalink
Post by Sunhux G
mutt & mailx are MUA (Message User Agent) while
postfix (& I think sendmail) have both MTA and MUA
functions (ie they can act as SMTP servers besides
as MUA).
That's mostly correct, but mailx can do what you need in this case,
without a local MTA. Here's a modified version of your original mutt
example but using mailx with an option to specify an external MTA.

$ mailx -s "Test mail" -a /tmp/file.tar.gz -S "smtp=your.relayhost.here"
Post by Sunhux G
I guess mailx will require sendmail.cf to be edited as
well: if only we have sort of script that does something
like the telnet & the series of HELO...DATA commands,
that will be wonderful (as I think it doesn't require an
MTA (eg: sendmail & postfix) to be running.
Sendmail was the default MTA in RHEL5, Postfix in RHEL 6. Both are
reasonably locked down to accept mail only on the loopback as I recall, so
not much of a risk, at least from the network, IMO. There are benefits to
running a local MTA vs the mailx example as well, namely a MTA will queue
and retry if the remote relay is unavailable for some reason. That being
said, if you can't or don't want to use a local MTA, the mailx example
should work.
Post by Sunhux G
Correct me if my understanding is incorrect.
SH
On Wed, Jul 16, 2014 at 10:26 AM, Fred Smith
Post by Fred Smith
Post by Sunhux G
Thanks Fred.
Sendmail was listed by our audit as a non-secure
service. Must sendmail be started or is there any
other alternative to send email?
there are other tools to do a similar job, but the only one
I've used, personally, is sendmail. I think Postfix is another
one that may be in Centos, though I have no experience with it.
Post by Sunhux G
Think in Windows environment, blat & sendemail
doesn't require an equivalent service to work so
if there is some other ways of sending email, will
(does anyone has a script that could read in the
content of a text file, ie line 1-3 below & then
# telnet SMTP_Relay_IP 25
HELO
501 Syntax: HELO hostname
HELO smtp.mypostfixdomain.com
250 hostname.mypostfixdomain.com
250 2.1.0 Ok
HELO smtp.mypostfixdomain.com
250 hostname.mypostfixdomain.com
250 2.1.0 Ok
250 2.1.5 Ok
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
line 1
line 2
line 3
*.*
250 2.0.0 Ok: queued as BAF8A200034
On Wed, Jul 16, 2014 at 12:58 AM, Fred Smith <
Post by Fred Smith
Post by Sunhux G
I have got the firewall rule permitted from our RHEL 5.x &
RHEL 6.x servers to our SMTP relay server (it's running
RHEL 5.8).
In the past, I recall I have a server that I could just issue
mutt command below & it will send email out via that
/tmp/mailmessage.txt
Now all my servers (at another site) can't send email out.
Did I need to set something at this site's server or is
there any way that I could specify the SMTP relay server
in the mutt command? In Windows, blat & sendemail
allows me to specify the SMTP relay server.
Assuming you've got sendmail installed, and are using the default sendmail.cf,
cd /etc/mail
vi sendmail.cf
search for a line beginning with "DS", with a comment above it
"Smart" relay host (may be null)
and change the line that reads just "DS" to read
"DSyoursmarthost.foo"
Post by Sunhux G
Post by Fred Smith
or whatever the FQDN is of your smart relay host. there is NOT a
space
Post by Sunhux G
Post by Fred Smith
between the "DS" and the FQDN.
you'll probably need to restart the sendmail service afterward.
--
-----------------------------
Show me your ways, O LORD, teach me your paths;
Guide me in your truth and teach me,
for you are God my Savior,
And my hope is in you all day long.
-------------------------- Psalm 25:4-5 (NIV)
--------------------------------
--
redhat-list mailing list
unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
-----------------------------
"For the word of God is living and active. Sharper than any double-edged
sword, it penetrates even to dividing soul and spirit, joints and marrow;
it judges the thoughts and attitudes of the heart."
---------------------------- Hebrews 4:12 (niv)
------------------------------
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
James Jones
2014-07-16 15:22:16 UTC
Permalink
It been about 20 years since I have used it but you may want to look at
expect. It is a scripting tool that I used in a project to pull off
statistics from cisco equipment and store in a file years ago. It may
solve your problem.

jim
Post by Sunhux G
Thanks Fred.
Sendmail was listed by our audit as a non-secure
service. Must sendmail be started or is there any
other alternative to send email?
Think in Windows environment, blat & sendemail
doesn't require an equivalent service to work so
if there is some other ways of sending email, will
(does anyone has a script that could read in the
content of a text file, ie line 1-3 below & then
# telnet SMTP_Relay_IP 25
HELO
501 Syntax: HELO hostname
HELO smtp.mypostfixdomain.com
250 hostname.mypostfixdomain.com
250 2.1.0 Ok
HELO smtp.mypostfixdomain.com
250 hostname.mypostfixdomain.com
250 2.1.0 Ok
250 2.1.5 Ok
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
line 1
line 2
line 3
*.*
250 2.0.0 Ok: queued as BAF8A200034
On Wed, Jul 16, 2014 at 12:58 AM, Fred Smith <
Post by Fred Smith
Post by Sunhux G
I have got the firewall rule permitted from our RHEL 5.x &
RHEL 6.x servers to our SMTP relay server (it's running
RHEL 5.8).
In the past, I recall I have a server that I could just issue
mutt command below & it will send email out via that
/tmp/mailmessage.txt
Now all my servers (at another site) can't send email out.
Did I need to set something at this site's server or is
there any way that I could specify the SMTP relay server
in the mutt command? In Windows, blat & sendemail
allows me to specify the SMTP relay server.
Assuming you've got sendmail installed, and are using the default sendmail.cf,
cd /etc/mail
vi sendmail.cf
"Smart" relay host (may be null)
and change the line that reads just "DS" to read "DSyoursmarthost.foo"
or whatever the FQDN is of your smart relay host. there is NOT a space
between the "DS" and the FQDN.
you'll probably need to restart the sendmail service afterward.
--
-----------------------------
Show me your ways, O LORD, teach me your paths;
Guide me in your truth and teach me,
for you are God my Savior,
And my hope is in you all day long.
-------------------------- Psalm 25:4-5 (NIV)
--------------------------------
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
James R. Jones
Manager of Campus Operations
UAF-BBC
PO Box 1070
Dillingham, AK 99576
907-842-8312
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Sunhux G
2014-07-17 11:37:27 UTC
Permalink
What Harris gave with mailx is probably what I'm looking for,
just that I can't get the syntax right with -a (or even if I leave
out the -a option) :

# mailx -s "test" -a /tmp/tst.tar.gz -S "smtp=172.20.1.92" ***@xxx.com
< /tmp/cis/group.tmp
Or (without the -u )
# mailx -s "test" -a /tmp/tst.tar.gz -u ***@xxx.com -S
"smtp=172.20.1.92" ***@xxx.com < /tmp/cis/group.tmp
mailx: invalid option -- a
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
[-- sendmail-options ...]
mail [-iInNv] -f [name]
mail [-iInNv] [-u user]
What did I miss? I've tried with uuencode (referring to some
examples on the Net) too but no joy


SH
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Sunhux G
2014-07-17 11:52:08 UTC
Permalink
Have to remove both -a & -S in order not to get the syntax
error but the emails never arrive:
(I'm able to 'telnet 172.20.1.92 25' from the server that mailx is issued
from)

# mailx -s "test5" -u root "smtp=172.20.1.92" ***@xxx.com <
/tmp/cis/group.tmp
Or
# mailx -s "test5" -u root "smtp=172.20.1.92:25" ***@xxx.com <
/tmp/cis/group.tmp


If I issue just the command below from the sendmail relay
server itself (without the -S & without "smtp=IP_of_SMTP"),
the emails arrive:

mailx -s "from SMTP2 server" ***@xxx.com < /tmp/tst.dat

I browsed thru the man pages for mailx : can't
locate a -S or "smtp=a.b.c.d" option. Did I miss
something?
Post by Sunhux G
What Harris gave with mailx is probably what I'm looking for,
just that I can't get the syntax right with -a (or even if I leave
# mailx -s "test" -a /tmp/tst.tar.gz -S "smtp=172.20.1.92"
Or (without the -u )
mailx: invalid option -- a
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
[-- sendmail-options ...]
mail [-iInNv] -f [name]
mail [-iInNv] [-u user]
What did I miss? I've tried with uuencode (referring to some
examples on the Net) too but no joy
SH
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Harris, Don
2014-07-17 13:16:52 UTC
Permalink
Oops, I see now that the mailx on RHEL5 and RHEL6 and very different
beasts.

RHEL5: mailx-8.1.1-44.2.2
RHEL6: mailx-12.4-7.el6.x86_64 http://heirloom.sourceforge.net/mailx.html

The legacy mailx on RHEL5 doesn't support all those options. If it's
acceptable in your environment, you can get the newer "Heirloom" mailx
from the EPEL repository. Note that it's the "nail" package on EPEL. See
https://fedoraproject.org/wiki/EPEL

HTH,
Don
Post by Sunhux G
Have to remove both -a & -S in order not to get the syntax
(I'm able to 'telnet 172.20.1.92 25' from the server that mailx is issued
from)
/tmp/cis/group.tmp
Or
/tmp/cis/group.tmp
If I issue just the command below from the sendmail relay
server itself (without the -S & without "smtp=IP_of_SMTP"),
I browsed thru the man pages for mailx : can't
locate a -S or "smtp=a.b.c.d" option. Did I miss
something?
Post by Sunhux G
What Harris gave with mailx is probably what I'm looking for,
just that I can't get the syntax right with -a (or even if I leave
# mailx -s "test" -a /tmp/tst.tar.gz -S "smtp=172.20.1.92"
Or (without the -u )
mailx: invalid option -- a
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
[-- sendmail-options ...]
mail [-iInNv] -f [name]
mail [-iInNv] [-u user]
What did I miss? I've tried with uuencode (referring to some
examples on the Net) too but no joy
SH
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Sunhux G
2014-07-17 15:53:51 UTC
Permalink
To be sure I get this right, the bundled mailx in RHEL6.x support the option
-S "smtp=172.20.1.92" ? <== did I get this syntax right?

Do you have mailx from EPEL installed in your RHEL & does it run any
vulnerable services? We have regular VA scans so this might be one
consideration when I raise Change Requests to install it.

Heard of 'Expect' & TCL scripts but I'm quite handicapped with them.
A few years ago, I saw in one RHEL 4.x a Perl script that send
email (without using any tools like mutt/mailx) so if anyone happen
to have a copy to share, will save me the hassle of raising Change
Requests as Perl interpreter is present by default in RHEL 5.x and
putting in a Perl script doesn't need Change Requests.

We have mostly RHEL 5.x & only 20 odd RHEL 6.x.

My purpose was to email out outputs of 'last', 'lastlog' & 'getent'
on fortnight basis as part of user accounts re-certification audit.


Thanks
SH
Post by Harris, Don
Oops, I see now that the mailx on RHEL5 and RHEL6 and very different
beasts.
RHEL5: mailx-8.1.1-44.2.2
RHEL6: mailx-12.4-7.el6.x86_64 http://heirloom.sourceforge.net/mailx.html
The legacy mailx on RHEL5 doesn't support all those options. If it's
acceptable in your environment, you can get the newer "Heirloom" mailx
from the EPEL repository. Note that it's the "nail" package on EPEL. See
https://fedoraproject.org/wiki/EPEL
HTH,
Don
Post by Sunhux G
Have to remove both -a & -S in order not to get the syntax
(I'm able to 'telnet 172.20.1.92 25' from the server that mailx is issued
from)
/tmp/cis/group.tmp
Or
/tmp/cis/group.tmp
If I issue just the command below from the sendmail relay
server itself (without the -S & without "smtp=IP_of_SMTP"),
I browsed thru the man pages for mailx : can't
locate a -S or "smtp=a.b.c.d" option. Did I miss
something?
Post by Sunhux G
What Harris gave with mailx is probably what I'm looking for,
just that I can't get the syntax right with -a (or even if I leave
# mailx -s "test" -a /tmp/tst.tar.gz -S "smtp=172.20.1.92"
Or (without the -u )
mailx: invalid option -- a
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
[-- sendmail-options ...]
mail [-iInNv] -f [name]
mail [-iInNv] [-u user]
What did I miss? I've tried with uuencode (referring to some
examples on the Net) too but no joy
SH
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Sunhux G
2014-07-17 16:27:31 UTC
Permalink
http://superuser.com/questions/137461/does-mailx-send-mail-using-an-smtp-relay-or-does-it-directly-connect-to-the-targ

Is the above mailx example for RHEL 6.x's mailx?


Found a script below but not sure if it's Shell or how it should
be executed:

{
echo 'helo me'
echo 'MAIL FROM:<***@yourdomain.com>'
echo 'RCPT TO: <***@theirdomain.com>'
echo 'DATA'
echo -e 'To:***@theirdomain.com\nMIME-Version: 1.0
(mime-construct 1.9)\nContent-Type:
application/octet-stream\nContent-Transfer-Encoding: base64\n\n'
cat myattachment.bin | openssl base64
echo '.'
} | nc smtp.mydomain.org 25


SH
Post by Sunhux G
To be sure I get this right, the bundled mailx in RHEL6.x support the option
-S "smtp=172.20.1.92" ? <== did I get this syntax right?
Do you have mailx from EPEL installed in your RHEL & does it run any
vulnerable services? We have regular VA scans so this might be one
consideration when I raise Change Requests to install it.
Heard of 'Expect' & TCL scripts but I'm quite handicapped with them.
A few years ago, I saw in one RHEL 4.x a Perl script that send
email (without using any tools like mutt/mailx) so if anyone happen
to have a copy to share, will save me the hassle of raising Change
Requests as Perl interpreter is present by default in RHEL 5.x and
putting in a Perl script doesn't need Change Requests.
We have mostly RHEL 5.x & only 20 odd RHEL 6.x.
My purpose was to email out outputs of 'last', 'lastlog' & 'getent'
on fortnight basis as part of user accounts re-certification audit.
Thanks
SH
Post by Harris, Don
Oops, I see now that the mailx on RHEL5 and RHEL6 and very different
beasts.
RHEL5: mailx-8.1.1-44.2.2
RHEL6: mailx-12.4-7.el6.x86_64 http://heirloom.sourceforge.net/mailx.html
The legacy mailx on RHEL5 doesn't support all those options. If it's
acceptable in your environment, you can get the newer "Heirloom" mailx
from the EPEL repository. Note that it's the "nail" package on EPEL. See
https://fedoraproject.org/wiki/EPEL
HTH,
Don
Post by Sunhux G
Have to remove both -a & -S in order not to get the syntax
(I'm able to 'telnet 172.20.1.92 25' from the server that mailx is issued
from)
/tmp/cis/group.tmp
Or
/tmp/cis/group.tmp
If I issue just the command below from the sendmail relay
server itself (without the -S & without "smtp=IP_of_SMTP"),
I browsed thru the man pages for mailx : can't
locate a -S or "smtp=a.b.c.d" option. Did I miss
something?
Post by Sunhux G
What Harris gave with mailx is probably what I'm looking for,
just that I can't get the syntax right with -a (or even if I leave
# mailx -s "test" -a /tmp/tst.tar.gz -S "smtp=172.20.1.92"
Or (without the -u )
mailx: invalid option -- a
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
[-- sendmail-options ...]
mail [-iInNv] -f [name]
mail [-iInNv] [-u user]
What did I miss? I've tried with uuencode (referring to some
examples on the Net) too but no joy
SH
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Harris, Don
2014-07-18 02:32:07 UTC
Permalink
Post by Sunhux G
To be sure I get this right, the bundled mailx in RHEL6.x support the option
-S "smtp=172.20.1.92" ? <== did I get this syntax right?
Correct, the mailx with RHEL6 supports specifying a remote smtp server as
shown. If in doubt, read the man page and try it on a test system.
Post by Sunhux G
Do you have mailx from EPEL installed in your RHEL & does it run any
vulnerable services? We have regular VA scans so this might be one
consideration when I raise Change Requests to install it.
Mailx is called "nail² in the EPEL RHEL5 repo. nail is simply a
program that runs when you execute it from the command line or script.
There are no daemons that run in the background.

I don't know what your VA (vulnerability assessment?) scans entail, but if
they're scanning from the network, they'll never see it because it isn't
running and doesn't listen on any network ports. If they¹re scanning the
file system, it¹s just another package that needs to be kept up to date
like any other package. By all means, talk to your security/audit team
about it.
Post by Sunhux G
Heard of 'Expect' & TCL scripts but I'm quite handicapped with them.
A few years ago, I saw in one RHEL 4.x a Perl script that send
email (without using any tools like mutt/mailx) so if anyone happen
to have a copy to share, will save me the hassle of raising Change
Requests as Perl interpreter is present by default in RHEL 5.x and
putting in a Perl script doesn't need Change Requests.
We have mostly RHEL 5.x & only 20 odd RHEL 6.x.
My purpose was to email out outputs of 'last', 'lastlog' & 'getent'
on fortnight basis as part of user accounts re-certification audit.
A super simple shell script called from cron would do what you need. Just
test it from the shell first to get the command straight. For example, to
get the output mailed to you without using a temp file, just pipe the
command output to mailx like so:
‹‹
#!/bin/sh
last | mailx -s²last output from `hostname` on `date`² -S
³smtp=172.20.1.92² ***@your.domain

lastlog | mailx -s²lastlog output from `hostname` on `date`² -S
³smtp=172.20.1.92² ***@your.domain

getent passwd | mailx -s²getent output from `hostname` on `date`² -S
³smtp=172.20.1.92² ***@your.domain

‹‹

Again, this would work out-of-the-box with the mailx package provided in
RHEL6. For RHEL5, you¹ll need to get the ³nail" package from somewhere
else. I use and recommend the EPEL project repo for this kind of extra
package because it is run by Red Hat within the Fedora project. Lots of
supporting reasons here: https://fedoraproject.org/wiki/About_EPEL

Good luck!

Don
Post by Sunhux G
Thanks
SH
Post by Harris, Don
Oops, I see now that the mailx on RHEL5 and RHEL6 and very different
beasts.
RHEL5: mailx-8.1.1-44.2.2
RHEL6: mailx-12.4-7.el6.x86_64
http://heirloom.sourceforge.net/mailx.html
The legacy mailx on RHEL5 doesn't support all those options. If it's
acceptable in your environment, you can get the newer "Heirloom" mailx
from the EPEL repository. Note that it's the "nail" package on EPEL. See
https://fedoraproject.org/wiki/EPEL
HTH,
Don
Post by Sunhux G
Have to remove both -a & -S in order not to get the syntax
(I'm able to 'telnet 172.20.1.92 25' from the server that mailx is
issued
Post by Sunhux G
from)
/tmp/cis/group.tmp
Or
/tmp/cis/group.tmp
If I issue just the command below from the sendmail relay
server itself (without the -S & without "smtp=IP_of_SMTP"),
I browsed thru the man pages for mailx : can't
locate a -S or "smtp=a.b.c.d" option. Did I miss
something?
Post by Sunhux G
What Harris gave with mailx is probably what I'm looking for,
just that I can't get the syntax right with -a (or even if I leave
# mailx -s "test" -a /tmp/tst.tar.gz -S "smtp=172.20.1.92"
Or (without the -u )
mailx: invalid option -- a
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr
...
Post by Sunhux G
Post by Sunhux G
[-- sendmail-options ...]
mail [-iInNv] -f [name]
mail [-iInNv] [-u user]
What did I miss? I've tried with uuencode (referring to some
examples on the Net) too but no joy
SH
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Sunhux G
2014-07-18 11:09:12 UTC
Permalink
Found an RHEL 6.3 server to test out the mailx that supports -S :

# mailx -s "rh1 via smtp1" -a /tmp/tst.tar.gz -S "smtp=172.20.1.92"
***@gmail.com < /tmp/cis/group.tmp

smtp-server: 421 4.7.0 mailrelay2.z-cloud.gov.au closing connection
"/root/dead.letter" 87/2184
. . . message not sent.


What caused the above dead letter?

On that SMTP server 172.20.1.92, I certainly could send emails out using
mutt &
received them (without specifying the relay server) & I understand quite a
number of
current tenants are already successfully sending emails out via this SMTP
server.
Post by Harris, Don
Post by Sunhux G
To be sure I get this right, the bundled mailx in RHEL6.x support the option
-S "smtp=172.20.1.92" ? <== did I get this syntax right?
Correct, the mailx with RHEL6 supports specifying a remote smtp server as
shown. If in doubt, read the man page and try it on a test system.
Post by Sunhux G
Do you have mailx from EPEL installed in your RHEL & does it run any
vulnerable services? We have regular VA scans so this might be one
consideration when I raise Change Requests to install it.
Mailx is called "nail² in the EPEL RHEL5 repo. nail is simply a
program that runs when you execute it from the command line or script.
There are no daemons that run in the background.
I don't know what your VA (vulnerability assessment?) scans entail, but if
they're scanning from the network, they'll never see it because it isn't
running and doesn't listen on any network ports. If they¹re scanning the
file system, it¹s just another package that needs to be kept up to date
like any other package. By all means, talk to your security/audit team
about it.
Post by Sunhux G
Heard of 'Expect' & TCL scripts but I'm quite handicapped with them.
A few years ago, I saw in one RHEL 4.x a Perl script that send
email (without using any tools like mutt/mailx) so if anyone happen
to have a copy to share, will save me the hassle of raising Change
Requests as Perl interpreter is present by default in RHEL 5.x and
putting in a Perl script doesn't need Change Requests.
We have mostly RHEL 5.x & only 20 odd RHEL 6.x.
My purpose was to email out outputs of 'last', 'lastlog' & 'getent'
on fortnight basis as part of user accounts re-certification audit.
A super simple shell script called from cron would do what you need. Just
test it from the shell first to get the command straight. For example, to
get the output mailed to you without using a temp file, just pipe the
‹‹
#!/bin/sh
last | mailx -s²last output from `hostname` on `date`² -S
lastlog | mailx -s²lastlog output from `hostname` on `date`² -S
getent passwd | mailx -s²getent output from `hostname` on `date`² -S
‹‹
Again, this would work out-of-the-box with the mailx package provided in
RHEL6. For RHEL5, you¹ll need to get the ³nail" package from somewhere
else. I use and recommend the EPEL project repo for this kind of extra
package because it is run by Red Hat within the Fedora project. Lots of
supporting reasons here: https://fedoraproject.org/wiki/About_EPEL
Good luck!
Don
Post by Sunhux G
Thanks
SH
Post by Harris, Don
Oops, I see now that the mailx on RHEL5 and RHEL6 and very different
beasts.
RHEL5: mailx-8.1.1-44.2.2
RHEL6: mailx-12.4-7.el6.x86_64
http://heirloom.sourceforge.net/mailx.html
The legacy mailx on RHEL5 doesn't support all those options. If it's
acceptable in your environment, you can get the newer "Heirloom" mailx
from the EPEL repository. Note that it's the "nail" package on EPEL. See
https://fedoraproject.org/wiki/EPEL
HTH,
Don
Post by Sunhux G
Have to remove both -a & -S in order not to get the syntax
(I'm able to 'telnet 172.20.1.92 25' from the server that mailx is
issued
Post by Sunhux G
from)
/tmp/cis/group.tmp
Or
/tmp/cis/group.tmp
If I issue just the command below from the sendmail relay
server itself (without the -S & without "smtp=IP_of_SMTP"),
/tmp/tst.dat
Post by Sunhux G
Post by Harris, Don
Post by Sunhux G
I browsed thru the man pages for mailx : can't
locate a -S or "smtp=a.b.c.d" option. Did I miss
something?
Post by Sunhux G
What Harris gave with mailx is probably what I'm looking for,
just that I can't get the syntax right with -a (or even if I leave
# mailx -s "test" -a /tmp/tst.tar.gz -S "smtp=172.20.1.92"
Or (without the -u )
mailx: invalid option -- a
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr
...
Post by Sunhux G
Post by Sunhux G
[-- sendmail-options ...]
mail [-iInNv] -f [name]
mail [-iInNv] [-u user]
What did I miss? I've tried with uuencode (referring to some
examples on the Net) too but no joy
SH
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www
Sunhux G
2014-07-18 11:18:26 UTC
Permalink
Removed "-a /tmp/tst.tar.gz" & still get the same error.

Figured that /root/dead.letter is actually a logfile & its
contents is shown below:

# more /root/dead.letter

Date: Fri, 18 Jul 2014 19:01:58 +0800
From: ***@current_svr.mgmt.a-cloud.gov.au
To: ***@gmail.com
Subject: rh1 via smtp1
Message-ID: <53c8fea6.0u+3/R+bETa4Hsbt%***@current_svr.mgmt.a-cloud.gov.au>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="=_53c8fea6.QPYvMxRlHrS05uxwNfXaW0elMaSu2c32+VTgj87G8Ruar7Yz"
This is a multi-part message in MIME format.
--=_53c8fea6.QPYvMxRlHrS05uxwNfXaW0elMaSu2c32+VTgj87G8Ruar7Yz
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
root:x:0:
bin:x:1:bin,daemon
. . .
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Harris, Don
2014-07-18 11:58:21 UTC
Permalink
Post by Sunhux G
# mailx -s "rh1 via smtp1" -a /tmp/tst.tar.gz -S "smtp=172.20.1.92"
smtp-server: 421 4.7.0 mailrelay2.z-cloud.gov.au closing connection
"/root/dead.letter" 87/2184
. . . message not sent.
Your command is syntactically correct. The remote mail server is telling
you the service you’re requesting is not available. Try adding the verbose
(-v) option to your mailx command. This should give you a clearer picture
of where in the SMTP conversation you are being denied. If that doesn’t
clear it up for you, I recommend you consult with whomever runs the relay
at 172.20.1.92 and ask them to help troubleshoot the issue.
Post by Sunhux G
What caused the above dead letter?
On that SMTP server 172.20.1.92, I certainly could send emails out using
mutt &
received them (without specifying the relay server) & I understand quite a
number of
current tenants are already successfully sending emails out via this SMTP
server.
Post by Harris, Don
Post by Sunhux G
To be sure I get this right, the bundled mailx in RHEL6.x support the option
-S "smtp=172.20.1.92" ? <== did I get this syntax right?
Correct, the mailx with RHEL6 supports specifying a remote smtp server as
shown. If in doubt, read the man page and try it on a test system.
Post by Sunhux G
Do you have mailx from EPEL installed in your RHEL & does it run any
vulnerable services? We have regular VA scans so this might be one
consideration when I raise Change Requests to install it.
Mailx is called "nail² in the EPEL RHEL5 repo. nail is simply a
program that runs when you execute it from the command line or script.
There are no daemons that run in the background.
I don't know what your VA (vulnerability assessment?) scans entail, but if
they're scanning from the network, they'll never see it because it isn't
running and doesn't listen on any network ports. If they¹re scanning the
file system, it¹s just another package that needs to be kept up to date
like any other package. By all means, talk to your security/audit team
about it.
Post by Sunhux G
Heard of 'Expect' & TCL scripts but I'm quite handicapped with them.
A few years ago, I saw in one RHEL 4.x a Perl script that send
email (without using any tools like mutt/mailx) so if anyone happen
to have a copy to share, will save me the hassle of raising Change
Requests as Perl interpreter is present by default in RHEL 5.x and
putting in a Perl script doesn't need Change Requests.
We have mostly RHEL 5.x & only 20 odd RHEL 6.x.
My purpose was to email out outputs of 'last', 'lastlog' & 'getent'
on fortnight basis as part of user accounts re-certification audit.
A super simple shell script called from cron would do what you need. Just
test it from the shell first to get the command straight. For example, to
get the output mailed to you without using a temp file, just pipe the
‹‹
#!/bin/sh
last | mailx -s²last output from `hostname` on `date`² -S
lastlog | mailx -s²lastlog output from `hostname` on `date`² -S
getent passwd | mailx -s²getent output from `hostname` on `date`² -S
‹‹
Again, this would work out-of-the-box with the mailx package provided in
RHEL6. For RHEL5, you¹ll need to get the ³nail" package from somewhere
else. I use and recommend the EPEL project repo for this kind of extra
package because it is run by Red Hat within the Fedora project. Lots of
supporting reasons here: https://fedoraproject.org/wiki/About_EPEL
Good luck!
Don
Post by Sunhux G
Thanks
SH
Post by Harris, Don
Oops, I see now that the mailx on RHEL5 and RHEL6 and very different
beasts.
RHEL5: mailx-8.1.1-44.2.2
RHEL6: mailx-12.4-7.el6.x86_64
http://heirloom.sourceforge.net/mailx.html
The legacy mailx on RHEL5 doesn't support all those options. If it's
acceptable in your environment, you can get the newer "Heirloom"
mailx
Post by Sunhux G
Post by Harris, Don
from the EPEL repository. Note that it's the "nail" package on EPEL.
See
Post by Sunhux G
Post by Harris, Don
https://fedoraproject.org/wiki/EPEL
HTH,
Don
Post by Sunhux G
Have to remove both -a & -S in order not to get the syntax
(I'm able to 'telnet 172.20.1.92 25' from the server that mailx is
issued
Post by Sunhux G
from)
/tmp/cis/group.tmp
Or
/tmp/cis/group.tmp
If I issue just the command below from the sendmail relay
server itself (without the -S & without "smtp=IP_of_SMTP"),
/tmp/tst.dat
Post by Sunhux G
Post by Harris, Don
Post by Sunhux G
I browsed thru the man pages for mailx : can't
locate a -S or "smtp=a.b.c.d" option. Did I miss
something?
Post by Sunhux G
What Harris gave with mailx is probably what I'm looking for,
just that I can't get the syntax right with -a (or even if I leave
# mailx -s "test" -a /tmp/tst.tar.gz -S "smtp=172.20.1.92"
Or (without the -u )
mailx: invalid option -- a
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr]
to-addr
Post by Sunhux G
Post by Harris, Don
...
Post by Sunhux G
Post by Sunhux G
[-- sendmail-options ...]
mail [-iInNv] -f [name]
mail [-iInNv] [-u user]
What did I miss? I've tried with uuencode (referring to some
examples on the Net) too but no joy
SH
--
redhat-list mailing list
unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-***@redhat.com?subject=unsubscribe
https:
Loading...