Problem with sending mail using perl

K

Kimi

While trying to use this simple unix command to send mail using perl

#!/usr/bin/perl
my $output =`echo Mailbody | mail (e-mail address removed)`;

I am facing a strange issue where "(e-mail address removed)" gets converted to
"(e-mail address removed)" and the mail is sent to it. Could some
one throw pointers to get rid of the issue.

The above unix code works perfectly well when executed separately and
send mail to (e-mail address removed)

Thanks in Advance,
Fahad
 
B

Benoit Lefebvre

While trying to use this simple unix command to send mail using perl

#!/usr/bin/perl
my $output =`echo Mailbody | mail (e-mail address removed)`;

I am facing a strange issue where "(e-mail address removed)" gets converted to
"(e-mail address removed)" and the mail is sent to it. Could some
one throw pointers to get rid of the issue.

The above unix code works perfectly well when executed separately and
send mail to (e-mail address removed)

Thanks in Advance,
Fahad

Put a "\" in front of the "@"

#!/usr/bin/perl
my $output =`echo Mailbody | mail afa...\@VSNL.com`;
 
K

Kimi

Put a "\" in front of the "@"

#!/usr/bin/perl
my $output =`echo Mailbody | mail afa...\@VSNL.com`;


Thanks Benoit, That was helpful. But Is it how mail ids are supposed
to be used in perl in general. Suppose I am assigning the mail id to a
variable and want to use it,

Should it be again like,

#!/usr/bin/perl
$mail_id="afahad\@VSNL.com";
my $output =`echo Mailbody | mail $mail_id`;

Or is there a better way?

Thanks in Advance,
Kimi
 
B

Ben Morrow

Quoth Kimi said:
Thanks Benoit, That was helpful. But Is it how mail ids are supposed
to be used in perl in general. Suppose I am assigning the mail id to a
variable and want to use it,

@VSNL is a variable. Variables interpolate in "" strings. If you had put

use strict;
use warnings;

at the top of your script, Perl would have told you what was wrong.
Should it be again like,

#!/usr/bin/perl
$mail_id="afahad\@VSNL.com";
my $output =`echo Mailbody | mail $mail_id`;

Or is there a better way?

This is a perfectly good way, yes. Slightly clearer might be

$mail_id = '(e-mail address removed)';

note that I no longer have to use \@ as single quotes don't expand
variables.

Ben
 
K

Kimi

Quoth Kimi <[email protected]>:





@VSNL is a variable. Variables interpolate in "" strings. If you had put

use strict;
use warnings;

at the top of your script, Perl would have told you what was wrong.




This is a perfectly good way, yes. Slightly clearer might be

$mail_id = '(e-mail address removed)';

note that I no longer have to use \@ as single quotes don't expand
variables.

Ben


Thanks Ben.

-Kimi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top