amaterasu2915
12-07-2004, 08:53 PM
I believe I posted long ago w/ a technical question about operating a Linux server. People were really, really helpful (as I am a total Linux newbie), and I hope you can help me once again.
I am building a development server in preparation for the creation of a web site. The server will receive emails and identify the sender and recipient email addresses in each message, storing them in a database among other things.
I have (with the help of this community) arranged to have emails run through a Perl script by manipulating virtusertable and aliases (a titanic accomplishment for me.) I have installed the Perl module MailTools, and can use Mail::Internet to identify email addresses in the following complete form, for example:
Bob Smith <bob@att.net>
But I need the program to isolate the e-mail address alone, in other words:
bob@att.net
I have fought with my (very poor) Perl programming skills, but to no avail. The code (which I have been using) is something like this:
#! /usr/bin/perl
# /usr/local/bin/remailer.pl
use Mail::Internet;
use Mail::Address;
$mail = Mail::Internet->new( \*STDIN );
$sender=$mail->get('Reply-To') ||
$mail->get('From');
$sender=(Mail::Address->parse($sender))[0];
open (FH, '>/tmp/output.txt');
print FH @to;
print FH @from;
print FH $sender;
close (FH);
This code bit results in an error, saying: can't call method "address" on undefined value. The address method (I believe, but I could be wrong) should isolate the email address. It's meant to be a very simple test code: it receives an email text through standard input, identifies the full email addresses for recipient and sender, and then creates a file called output.txt that lists those full email addresses, as well as the email address of the sender, stripped of comments, name or greater and lesser signs.
As you can see, I am fairly new to programming, Unix and Linux. Any recommendations as to books, web sites or resources that would better answer these questions would be welcome. Some code ideas would be great too. I have searched hard for MailTools resources (cpan.org, googling MailTools, Mail::Internet, so on) but to no avail.
Thanks so much for helping an enthusiastic but often clueless Linux newbie. Please let me know if such questions are not relevant to this community too.
I am building a development server in preparation for the creation of a web site. The server will receive emails and identify the sender and recipient email addresses in each message, storing them in a database among other things.
I have (with the help of this community) arranged to have emails run through a Perl script by manipulating virtusertable and aliases (a titanic accomplishment for me.) I have installed the Perl module MailTools, and can use Mail::Internet to identify email addresses in the following complete form, for example:
Bob Smith <bob@att.net>
But I need the program to isolate the e-mail address alone, in other words:
bob@att.net
I have fought with my (very poor) Perl programming skills, but to no avail. The code (which I have been using) is something like this:
#! /usr/bin/perl
# /usr/local/bin/remailer.pl
use Mail::Internet;
use Mail::Address;
$mail = Mail::Internet->new( \*STDIN );
$sender=$mail->get('Reply-To') ||
$mail->get('From');
$sender=(Mail::Address->parse($sender))[0];
open (FH, '>/tmp/output.txt');
print FH @to;
print FH @from;
print FH $sender;
close (FH);
This code bit results in an error, saying: can't call method "address" on undefined value. The address method (I believe, but I could be wrong) should isolate the email address. It's meant to be a very simple test code: it receives an email text through standard input, identifies the full email addresses for recipient and sender, and then creates a file called output.txt that lists those full email addresses, as well as the email address of the sender, stripped of comments, name or greater and lesser signs.
As you can see, I am fairly new to programming, Unix and Linux. Any recommendations as to books, web sites or resources that would better answer these questions would be welcome. Some code ideas would be great too. I have searched hard for MailTools resources (cpan.org, googling MailTools, Mail::Internet, so on) but to no avail.
Thanks so much for helping an enthusiastic but often clueless Linux newbie. Please let me know if such questions are not relevant to this community too.