hi. i want to forward one email alias to my perl program. lets say i have an email address like post@anything.com and a perl file called post.pl now i want to configure the alias post@anything.com to be forwarded to my perl file and make the program grab the message and do anything i wrote in it. i think i could explain! please, someone help me! thankss...
[hr][b][e]agLrT[/b]
Comments
: [hr][b][e]agLrT[/b]
:
Could u clarify what u mean by forwarded by the perl file, do u mean like jus send the address to the perl file, or actually configure the dns to send the mail to the script.
-----------------------
[RED]Heero Yuy
Perl Board Moderator
Perl Semi-Expert[/RED]
: [hr][b][e]agLrT[/b]
:
Hi there,
Do you mean that you have an email and it's sent to post@anything.com and your Perl script has access to this mailbox. Once an email is sent, the Perl script reads the email and executes the instructions within the email?
Cya
Bradley q:)
: : [hr][b][e]agLrT[/b]
: :
:
: Hi there,
:
: Do you mean that you have an email and it's sent to post@anything.com and your Perl script has access to this mailbox. Once an email is sent, the Perl script reads the email and executes the instructions within the email?
:
: Cya
: Bradley q:)
:
not exactly access, i want to send the messages directly to the program... and the program will read the message and do what it has to. see?
: : [hr][b][e]agLrT[/b]
: :
:
: Could u clarify what u mean by forwarded by the perl file, do u mean like jus send the address to the perl file, or actually configure the dns to send the mail to the script.
: -----------------------
: [RED]Heero Yuy
: Perl Board Moderator
: Perl Semi-Expert[/RED]
:
:
i want to configure some of my mail addresses to go directly to the program. i mean, when you get new mail message it goes to its mailbox, but i do not want the messages stay in the mailbox, just go to the program... and let the program decide what to do... see?
-----------------------
[RED]Heero Yuy
Perl Board Moderator
Perl Semi-Expert[/RED]
:
:
: -----------------------
: [RED]Heero Yuy
: Perl Board Moderator
: Perl Semi-Expert[/RED]
:
:
no! just forget all you saw in my messages, lets take it again. for example; i have an email address (post@eaglort.com), someone sent a mail to that address to post a message (hi there...), and my program got the message (hi there...) from the body and saved it to a file. this is the event i want to do! i want to forward an email address (the message inside) to a perl program. see?
-----------------------
[RED]Heero Yuy
Perl Board Moderator
Perl Semi-Expert[/RED]
: [hr][b][e]agLrT[/b]
:
Hi
I've been working on a similar thing, I think you are wanting to use the Mail::Internet module.
I call my script via the aliases file but the same could be done from a .forward or procmail
The following code will handle getting an email piped to it:
###### begin code snippet #######
#!/usr/bin/perl -w
use Mail::Internet;
use Date::Parse;
#read the mail in from STDIN
$message = new Mail::Internet *STDIN;
#optionally remove blank lines at begining and end of email
$message->tidy_body();
#get the to field
$to = $message->get("To");
#get the from field
$from = $message->get("From");
#get the date field and convert it to another format suitable for mysql
$datestring = $message->get("Date");
($ss,$mm,$hh,$day,$month,$year,$zone) = strptime($datestring);
$date = "$year-$month-$day-$hh-$mm-$ss";
#get the subject field
$subject = $message->get("Subject");
#get the whole header text as a string
$header = $message->head->as_string;
#get the body and join it back together as one string
*body_array = $message->body();
$body = join '', @body_array;
####### end code snippet #######
the code above dosen't do anything with the email but I then stick it into a database or you could do what ever you want with it.
HTH
seaLne
: -----------------------
: [RED]Heero Yuy
: Perl Board Moderator
: Perl Semi-Expert[/RED]
:
:
thanks anyway. i am just asking what you told, the configuration.. take a look at sealne's message...
[hr][b][e]agLrT[/b]
:
: [hr][b][e]agLrT[/b]
:
:
an example in a sendmail aliases file would be:
[code]emailaddress: "|/path/to/my/script.pl"[/code]
in a .forward file to forward all mail going to that account to the script add the following line:
[code]"|/path/to/my/script.pl"[/code]
HTH
seaLne
[hr][b][e]agLrT[/b]