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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
11-10-2009, 08:30 AM
|
#1
|
Member
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707
Rep:
|
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.
|
|
|
11-10-2009, 08:47 AM
|
#2
|
Senior Member
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137
Rep:
|
Quote:
Originally Posted by vinaytp
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
|
|
|
11-10-2009, 09:00 AM
|
#3
|
LQ Newbie
Registered: Nov 2009
Location: Chinese
Distribution: Centos 5.2
Posts: 23
Rep:
|
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.
|
|
|
11-10-2009, 07:34 PM
|
#4
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,415
|
|
|
|
11-11-2009, 01:12 AM
|
#5
|
Member
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707
Original Poster
Rep:
|
Quote:
Originally Posted by cs24
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.
|
|
|
11-11-2009, 03:24 AM
|
#6
|
LQ Newbie
Registered: Nov 2009
Location: Chinese
Distribution: Centos 5.2
Posts: 23
Rep:
|
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 .
|
|
|
11-11-2009, 03:31 AM
|
#7
|
Member
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707
Original Poster
Rep:
|
Quote:
Originally Posted by cs24
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....
|
|
|
11-11-2009, 03:49 AM
|
#8
|
LQ Newbie
Registered: Nov 2009
Location: Chinese
Distribution: Centos 5.2
Posts: 23
Rep:
|
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.
|
|
|
11-11-2009, 08:14 PM
|
#9
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,415
|
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
|
|
|
All times are GMT -5. The time now is 03:45 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|