LinuxQuestions.org
Help answer threads with 0 replies.
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-10-2009, 08:30 AM   #1
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
sending mail through sendmail


Hi all...

I have to send mail from my linux machine to our company email server..I am planing to configure a sendmail server for that locally in my machine...

I have to write a script that should run a cron job once in 10 minutes that will check for particular keyword in /var/log/message file and send email to my office email id...

How can i best accomplish...Any suggestions....Pls

Awaiting for positive replys...

Any help will be appreciated...

Thanks in advance.....

Last edited by vinaytp; 11-10-2009 at 08:33 AM.
 
Old 11-10-2009, 08:47 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by vinaytp View Post
Hi all...

I have to send mail from my linux machine to our company email server..I am planing to configure a sendmail server for that locally in my machine...

I have to write a script that should run a cron job once in 10 minutes that will check for particular keyword in /var/log/message file and send email to my office email id...

How can i best accomplish...Any suggestions....Pls

Awaiting for positive replys...

Any help will be appreciated...

Thanks in advance.....

I think a better option would be a script that tails the message log and emails you when it finds and instance of the keyword??
better still there are apps that can do this for you. once called swatch and logging software called syslog-ng - which replaces the normal syslog software
 
Old 11-10-2009, 09:00 AM   #3
cs24
LQ Newbie
 
Registered: Nov 2009
Location: Chinese
Distribution: Centos 5.2
Posts: 23

Rep: Reputation: 1
It's not necessary to confige a sendmail to send mail to company email server.There are some script which can send mail by SMTP server.I can give you some example about send mail script .but you need to writing the script to "check for particular keyword in /var/log/message file"
Code:
#!/usr/bin/perl -w
use Net::SMTP_auth;
use Time::Local;
use Sys::Hostname;

$username='abc';
$password='abc';
$smtp = Net::SMTP->new('domainname',Hello =>'domainname');
$smtp->auth($username,$password);
$smtp->mail('abc@domainname');
$smtp->to('abc@gmail.com');
$smtp->data();
$smtp->datasend("hello world ! \n");
$smtp->quit;

Last edited by cs24; 11-10-2009 at 07:31 PM.
 
Old 11-10-2009, 07:34 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
The Perl module for tailing a file is http://search.cpan.org/~mgrabnar/Fil...0.99.3/Tail.pm

HTH
 
Old 11-11-2009, 01:12 AM   #5
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by cs24 View Post
It's not necessary to confige a sendmail to send mail to company email server.There are some script which can send mail by SMTP server.I can give you some example about send mail script .but you need to writing the script to "check for particular keyword in /var/log/message file"
Code:
#!/usr/bin/perl -w
use Net::SMTP_auth;
use Time::Local;
use Sys::Hostname;

$username='abc';
$password='abc';
$smtp = Net::SMTP->new('domainname',Hello =>'domainname');
$smtp->auth($username,$password);
$smtp->mail('abc@domainname');
$smtp->to('abc@gmail.com');
$smtp->data();
$smtp->datasend("hello world ! \n");
$smtp->quit;
Hi cs24

I am trying with this...but i am getting following error

Can't locate Net/SMTP_auth.pm in @INC...

Can you pls tell me whats the module i need to install for smtp to work...

Last edited by vinaytp; 11-11-2009 at 01:14 AM.
 
Old 11-11-2009, 03:24 AM   #6
cs24
LQ Newbie
 
Registered: Nov 2009
Location: Chinese
Distribution: Centos 5.2
Posts: 23

Rep: Reputation: 1
oh.sorry about that .I forgot I had installed the module .the module is "Net-SMTP_auth-0.08.tar.gz".may be you can download from some sites .
 
Old 11-11-2009, 03:31 AM   #7
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by cs24 View Post
oh.sorry about that .I forgot I had installed the module .the module is "Net-SMTP_auth-0.08.tar.gz".may be you can download from some sites .
Many Many Thanks cs24...

Code:
#!/usr/bin/perl -w
use Net::SMTP_auth;
use Time::Local;
use Sys::Hostname;
#
#$username='abc';
#$password='abc';
$smtp = Net::SMTP->new('linux.com',Hello =>'linux.com');
#$smtp->auth($username,$password);
$smtp->mail('vinay@vinay.linux.com');
$smtp->to('vinay@vinay.linux.com');
$smtp->data();
$smtp->datasend("hello world ! \n");
$smtp->quit;
This code is executing fine...But i am not able to receive any mail...my smtp port 25 is open..also dns is running and able to ping vinay.linux.com

Code:
nmap localhost
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
25/tcp   open  smtp
Pls help me....
 
Old 11-11-2009, 03:49 AM   #8
cs24
LQ Newbie
 
Registered: Nov 2009
Location: Chinese
Distribution: Centos 5.2
Posts: 23

Rep: Reputation: 1
I telnet the vinay.linux.com 25 port it's not open .maybe the mailserver is your private mailserver.anyway ,you need to test the vinay.linux.com domain can send mail.you may be send a mail by the normal client ,like outlook. to test the vinay.linux.com is fine.
and maybe the
Code:
$smtp = Net::SMTP->new('linux.com',Hello =>'linux.com');
linux.com can replace by vinay.linux.com to try again.
 
Old 11-11-2009, 08:14 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Are you trying to recv mail on localhost or your eth0 IP?
By default at install, sendmail only listens on localhost (127.0.0.1).
http://www.linuxtopia.org/online_boo...l-mta-sendmail
 
  


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
Sendmail (mailserver) -- sending mail with the mail command -- doesn't work :-( carolinevdh Linux - Server 1 08-13-2009 10:43 PM
Sendmail... or rather, sending mail rhide Linux - Newbie 4 06-08-2007 06:49 AM
Sendmail not sending mail tarheel92x Linux - Server 8 10-27-2006 05:44 AM
sendmail not sending mail dtra Linux - Software 1 06-09-2005 08:47 PM
sendmail not sending mail clinger Linux - Software 8 07-30-2004 03:29 AM


All times are GMT -5. The time now is 05:40 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