Problem with sending mail using perl

Problem with sending mail using perl

am 05.09.2007 17:12:43 von Kimi

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

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

I am facing a strange issue where "afahad@VSNL.com" gets converted to
"afahad.com@LocalHost.Local" 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 afahad@VSNL.com

Thanks in Advance,
Fahad

Re: Problem with sending mail using perl

am 05.09.2007 17:14:44 von Benoit Lefebvre

On Sep 5, 11:12 am, Kimi wrote:
> While trying to use this simple unix command to send mail using perl
>
> #!/usr/bin/perl
> my $output =`echo Mailbody | mail afa...@VSNL.com`;
>
> I am facing a strange issue where "afa...@VSNL.com" gets converted to
> "afahad....@LocalHost.Local" 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 afa...@VSNL.com
>
> Thanks in Advance,
> Fahad

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

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

Re: Problem with sending mail using perl

am 05.09.2007 17:27:01 von Kimi

On Sep 5, 8:14 pm, Benoit Lefebvre wrote:
> On Sep 5, 11:12 am, Kimi wrote:
>
> > While trying to use this simple unix command to send mail using perl
>
> > #!/usr/bin/perl
> > my $output =`echo Mailbody | mail afa...@VSNL.com`;
>
> > I am facing a strange issue where "afa...@VSNL.com" gets converted to
> > "afahad....@LocalHost.Local" 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 afa...@VSNL.com
>
> > Thanks in Advance,
> > Fahad
>
> 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

Re: Problem with sending mail using perl

am 05.09.2007 18:14:17 von veatchla

Kimi wrote:
> On Sep 5, 8:14 pm, Benoit Lefebvre wrote:
>> On Sep 5, 11:12 am, Kimi wrote:
>>
>>> While trying to use this simple unix command to send mail using perl
>>> #!/usr/bin/perl
>>> my $output =`echo Mailbody | mail afa...@VSNL.com`;
>>> I am facing a strange issue where "afa...@VSNL.com" gets converted to
>>> "afahad....@LocalHost.Local" 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 afa...@VSNL.com
>>> Thanks in Advance,
>>> Fahad
>> 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
>
>

I generally use Mail::Sender for my Perl emailing needs.

--

Len

Re: Problem with sending mail using perl

am 05.09.2007 18:48:46 von Ben Morrow

Quoth Kimi :
> On Sep 5, 8:14 pm, Benoit Lefebvre wrote:
> > On Sep 5, 11:12 am, Kimi wrote:
> >
> > > While trying to use this simple unix command to send mail using perl
> >
> > > #!/usr/bin/perl
> > > my $output =`echo Mailbody | mail afa...@VSNL.com`;
> >
> > > I am facing a strange issue where "afa...@VSNL.com" gets converted to
> > > "afahad....@LocalHost.Local" 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 afa...@VSNL.com
> >
> > 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,

@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 = 'afahad@VSNL.com';

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

Ben

Re: Problem with sending mail using perl

am 06.09.2007 11:21:25 von Kimi

On Sep 5, 9:48 pm, Ben Morrow wrote:
> Quoth Kimi :
>
>
>
> > On Sep 5, 8:14 pm, Benoit Lefebvre wrote:
> > > On Sep 5, 11:12 am, Kimi wrote:
>
> > > > While trying to use this simple unix command to send mail using perl
>
> > > > #!/usr/bin/perl
> > > > my $output =`echo Mailbody | mail afa...@VSNL.com`;
>
> > > > I am facing a strange issue where "afa...@VSNL.com" gets converted to
> > > > "afahad....@LocalHost.Local" 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 afa...@VSNL.com
>
> > > 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,
>
> @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 = 'afahad@VSNL.com';
>
> note that I no longer have to use \@ as single quotes don't expand
> variables.
>
> Ben


Thanks Ben.

-Kimi