Search:  

 
 
   All ForumsHot TopicsGallery






how-to block ads


 
Forums » Tech and Talk » OS and Software » All Things Unix » modifying perl script
Search Topic:
Uniqs:
246
Share Topic:
RSS topic:
toggle:
flat / full
normal / watch
Posting:
Post a:
Post a:
Supporting my elderly mom's Linux »
« ubuntu 9.04 64-bit application suggestions  
AuthorAll Replies

reaky

join:2004-01-18
Killeen, TX

modifying perl script

Hi freinds
I have a small problem I want u to help me in, I have a syslog server and configured it to send me email automatically, I get a small perl script to help me in, and tested it to send alerts to root and it worked successfully without any problems
Now I want to send it outside, I configured my sendmail to use my email server as SMARTHOST , and tested it by sending email like the following and it delevered successfuly
mail -s test reaky@domain.com -- -r reaky@server.com

Now I tried to use my perl script to use to out side reaky@domain.com, but It doesn't work, the perl script using sendmail -t instead of mail, So what I want to do is modifying this script to use the command: mail -s test reaky@domain.com -- -r reaky@server.com when sending the message

the following is the perl script:
=================================
#!/usr/bin/perl -n
# thanks to Brian Dowling for an example with security in mind.

$TO = 'bassam@tedata.net';
$FROM = $TO;

s/^//;

open(MAIL, "|/usr/sbin/sendmail -t");

print MAIL "EOT";
To: $TO
From: $FROM
Subject: SME Log Alert: $_

$_

EOT

close(MAIL);
======================================

Thanks for help

reaky

join:2004-01-18
Killeen, TX

I think we can use something like that
==============
#! /bin/sh
SUBJECT=”SET-EMAIL-SUBJECT”
EMAIL=”mymail@ad.dy”
EMAILMESSAGE=”pathtofile”

echo “This is an email message test” > $EMAILMESSAGE
echo “This is email text” >> $EMAILMESSAGE

/bin/mail -s “$SUBJECT” “$EMAIL”
================
But How to modify EMAILMESSAGE=”pathtofile” , to be input to the script

reaky

join:2004-01-18
Killeen, TX

reply to reaky
I think I know the problem now but I don't know how to solve it
the problem that the sendmail command still using root@localhost.localdomain when sending, Which is rejected
Look to the delevery failier:
==========================
The original message was received at Mon, 6 Jul 2009 11:16:03 +0300
from blackreaper [127.0.0.1]

----- The following addresses had permanent fatal errors -----

(reason: 554 mailfrom without country or top level domain is administratively denied)

----- Transcript of session follows -----
... while talking to out.tedata.net.eg.:
>>> MAIL From:
554 mailfrom without country or top level domain is administratively denied
554 5.0.0 Service unavailable

[-- Attachment #2 --]
[-- Type: message/delivery-status, Encoding: 7bit, Size: 0.3K --]

Reporting-MTA: dns; localhost.localdomain
Received-From-MTA: DNS; blackreaper
Arrival-Date: Mon, 6 Jul 2009 11:16:03 +0300

Final-Recipient: RFC822; reaky@domain.comt
Action: failed
Status: 5.0.0
Diagnostic-Code: SMTP; 554 mailfrom without country or top level domain is administratively denied
Last-Attempt-Date: Mon, 6 Jul 2009 11:16:03 +0300

[-- Attachment #3 --]
[-- Type: message/rfc822, Encoding: 7bit, Size: 0.8K --]

Date: Mon, 6 Jul 2009 11:16:03 +0300
To: reaky@domain.com
From: reaky@domain.com
Subject: SME Log Alert: Jul 6 11:15:21 Central.mc.tedata.net/Central.mc.tedata.net sshd[7527]: pam_unix(sshd:session):
+session opened for user amrali by (uid=0)
====================
How to solve this ?


koitsu
Premium
join:2002-07-16
Mountain View, CA

And then I sent you an Email with a Subject line of `rm -fr /` and watched your entire machine get destroyed.

Try using perl with the Net::SMTP module. It's *incredibly* easy to use, and reliable. Do not rely on calling sendmail/mailx/whatever-else -- you're asking for trouble.
--
Making life hard for others since 1977.
I speak for myself and not my employer/affiliates of my employer.

reaky

join:2004-01-18
Killeen, TX


1 edit
reply to reaky
I got your Idea, But May be It some blind for me to solve it, How can I use the perl with the module Net::SMTP ?
Ant way I solved the send problem now, with changing the LOCAL_DOMAIN in sendmail.mc
But there's still another problem that I have to restart syslog-ng first to send emails outside , in spite of It worked fine when trying to sending to inside users
Do you have any idea of the reason ?

(Note) I'm asking now the same question in another topic created for another issue,

»Sending emails via syslog-ng


koitsu
Premium
join:2002-07-16
Mountain View, CA

reply to reaky
»search.cpan.org/~gbarr/libnet-1.···/SMTP.pm

The example code and documentation should be sufficient.
--
Making life hard for others since 1977.
I speak for myself and not my employer/affiliates of my employer.
-
Forums » Tech and Talk » OS and Software » All Things UnixSupporting my elderly mom's Linux »
« ubuntu 9.04 64-bit application suggestions  


Wednesday, 02-Dec 20:38:59 Terms of Use | Privacy Policy | Hosting by www.nac.net - DSL,Hosting & Co-lo | feedback | contact
over 10 years online! © 1999-2009 dslreports.com.
page compression OFF
Most commented news this week
· [161] Comcast Releasing Promised Usage Meter
· [93] Graduate Student Unveils Sprint's GPS Sharing With Feds
· [79] Latest Consumer Reports Survey Not Kind To AT&T
· [70] Baltimore To Ban Lazy Cable Installs
· [62] Broadband Killed The Game Console
· [54] Rogers Unveils The ISP Dream Model
· [46] ACTA: Global Three Strikes
· [41] Rural Carriers Quickly Embracing Fiber
· [38] Charter Exits Chapter 11
· [38] AT&T, Verizon Drop 3G Ad Dispute
Most people now reading
· False positive in Avast! or is it real? [Security]
· MS admits Windows Updates principally created to annoy [Security]
· IMG 1.7 (IMG Updates and Discussion) [Verizon FIOS TV]
· [Newsgroups] Newzleech down? [Filesharing Software]
· LFM Overkill [World of Warcraft]
· Quality/longevity of 15A 120V receptacles [Home Repair & Improvement]
· Ooma changing features [VOIP Tech Chat]
· New Vizio 55" LED (VF551XVT) [Verizon FIOS TV]
· Furnace starts, then shuts off. [Home Repair & Improvement]
· HOW-TO: QoS and Tomato (fixes "choppy voice") [MagicJack]