Operating System - Linux
1820623 Members
2319 Online
109626 Solutions
New Discussion юеВ

automatic mail from linux

 

automatic mail from linux

Hi,

Through scripts, if i need to send mails automatically to any email id (internet mails or office mail), what & how should i configure that on linux? Please help?

Thanks in advance,
Kusuma
8 REPLIES 8
Mobeen_1
Esteemed Contributor

Re: automatic mail from linux

Kusuma,
For this you would need to configure sendmail on the Linux server. Please review the links below, they provide sufficient information on how to configure the same

http://www.siliconvalleyccie.com/linux-hn/sendmail.htm

http://www.linuxjournal.com/article.php?sid=5507

If you have any specific questions, let me know

regards
Mobeen
Kiyoshi Miyake
Frequent Advisor

Re: automatic mail from linux

Hi,

If you have sendmail on localsoft, you can use sendmail (mail command).
e.g.)
$ mail -s Subject user@domain < conts.txt

If you don't have sendmail or don't configure sendmail,
you can use perl.
Please see perldoc Net::SMTP.
Very simple script makes you happy.

e.g.)
#!/usr/bin/perl -w

use Net::SMTP;

$smtp = Net::SMTP->new('mailhost');

$smtp->mail($ENV{USER});
$smtp->to('postmaster');

$smtp->data();
$smtp->datasend("To: postmaster\n");
$smtp->datasend("\n");
$smtp->datasend("A simple test message\n");
$smtp->dataend();

$smtp->quit;
--- from perldoc Net::SMTP ---

Thanks.

Re: automatic mail from linux

Hello Mobeen,

does that mean that I have to have DNS if I have to send mails outside or is there any other option?

Kusuma
Mobeen_1
Esteemed Contributor

Re: automatic mail from linux

Kusuma,
Absolutely. You should have a DNS on your domain. I am not aware of any other ways this can be done.

regards
Mobeen
Roberto Polli
Trusted Contributor

Re: automatic mail from linux

If you're doing it for job:
1) select a mail server [postfix|sendmail]
2) read docs and configure it. It takes 1h using a ready-made config file.
3) use the "mail" command to send mail as suggested above. You can use it too thru piping:

echo "My Mail Body"|mail johnsmith@example.com -c johnholmes@example1.net


Peace, R>
Steven E. Protter
Exalted Contributor

Re: automatic mail from linux

attaching a useful script for sending attachments.

You can do mail so many different ways.

mail, elm, sendmai all have different and complimentary capabilities.

the right tool for the right job.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Nicholas Melville
New Member

Re: automatic mail from linux

I would suggest you use postfix. Simple to set up. Set the server to use your office mail server as its relayhost. It can handle where the mail should go.
In theory there is no difference between theory and practice, but in practice there is.
Derek Whitten
Advisor

Re: automatic mail from linux

I agree with Kiyoshi ... use some kind of perl/shell script that is called from cron.