Results 1 to 7 of 7
Hi forum,
I searched several hours in the Internet, but can't figure it out. I have to configure automatical trap mails on a SLES 10 server (HP Proliant). To test ...
- 09-19-2011 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 1
How to send mail from command line?
Hi forum,
I searched several hours in the Internet, but can't figure it out. I have to configure automatical trap mails on a SLES 10 server (HP Proliant). To test the basic functionality of emails on that machine at all I tried the following on command line:
sendmail -s "Test" [external email address]
But it does not work, nothing happens. I guess the problem is that the server does not know which SMTP server to use (it's in the same local network, same subnet and is an MS-Exchange-Server, relaying I already allowed for Linux server).
My problem with all I read about that is, that there is a huge amount of hints for countless mail clients (Mail, Mailx, Sendmail, Postfix, Mutt etc.) and hints to create configuration files. But the name of this file is differnt in every post I read ("mail.rc", "mailrc", ".mailrc", "mail.cf", "sendmail.cf", "mail.conf" etc.) And the folders, where these configuration files should reside, are different also: "etc", "root", "etc/mail".
I can't hack it, who can help? My aim is to teach Linux server to hand over automatically (without logged on root user) generated emails with an external mail address to that Exchange server - it's not important to me which mail application is used. How can I test mail functionallity when logged on as root user?
Thanks a lot for any help,
Stefano
- 09-19-2011 #2Just Joined!
- Join Date
- May 2006
- Posts
- 6
Try msmtp and mutt.
- 09-19-2011 #3Just Joined!
- Join Date
- Sep 2007
- Posts
- 51
- 09-20-2011 #4Just Joined!
- Join Date
- Jan 2011
- Location
- Fairfax, Virginia, USA
- Posts
- 94
Hi Stefano,
Mail is really confusing on Unix and Linux if you use the default tools. To send mail in scripts and on the command line, I just use the mail program which connects to my sendmail server and delivers email to another SMTP server. Someday I'll learn something easier and more practical, but for now I'm in the same boat your in.
I'm no expert on hacking on sendmail's configuration files, but I think I can get you going. I think you want to pay attention to places that suggest you modify sendmail.mc. When you run a preprocessor called m4 on this file, it produces sendmail.cf which is what sendmail reads. Its really really difficult (for me at least) to understand what goes on inside the .cf file so its nice to operate on the .mc level.
This is the URL I use to configure sendmail to forward encrypted mail through gmail. It works and I think it might be what you need to get started.
Linux Home Automation - Sendmail/Gmail
When you think about it, it should be practical to use a user space application that just connects to the destination SMTP server on port TCP/25 (I seem to recall there is a command line program called nail that does this but I might be wrong) , but there are benifits to using sendmail ... specifically, it will keep trying to deliver mail in case of failure.
- 09-20-2011 #5
If you don't want to run sendmail in daemon mode, you probably just need to set the DS macro in /etc/mail/submit.cf to point to your Exchange server.
- 10-27-2011 #6Just Joined!
- Join Date
- Oct 2011
- Posts
- 22
Try to install sendEmail (not sendmail), it's easy to use.
caspian.dotconf.net/menu/Software/SendEmail/Last edited by MikeTbob; 10-27-2011 at 11:27 AM.
- 10-27-2011 #7
A simple script can help test:
You can point it to whatever email address.Code:myscript.sh #!/bin/sh BODY="Some string" BODY="Line 1" BODY2="Blank" BODY3="Blank" BODY4="Line4" EMAIL=$1 if [ -n "${BODY}" ]; then ( echo "Subject: $SUBJECT"; echo "To: $EMAIL"; echo "From: Me <me@blah.com>"; echo; echo "$BODY" echo "$BODY2" echo "$BODY3" echo "$BODY4" ) | /usr/lib/sendmail -f Me $EMAIL fi
e.g: ./myscript.sh test@test.comlinux user # 503963


Reply With Quote
