Send::Mail nothing happens and no errors

Send::Mail nothing happens and no errors

am 25.01.2007 16:09:18 von Andy

I'm using the perl module Email::Send to generate email. In my tests,
the send function executes and no errors are thrown. But, even though
I'm sending the email to myself through my local SMTP email server to
my local exchange server, nothing seems to happen.

I'm also using Email::MIME and Email::MIME::Creator to build the email
headers.


Does anyone have any suggestions on what is going wrong or how to
diagnose the problem?


I'm running PERL on a windows platform; here's the code I'm calling to
send the email:

use Email::MIME;
use Email::MIME::Creator;
use Email::Send qw:SMTP:;

SendEmail("test","test","anedza@prodigysys.com","anedza@prod igysys.com","test","127.0.0.1");


#SendEmail($html,$text,$sender,$recipient,$subject,$smtpserv er);
sub SendEmail{
($html,$text,$sender,$recipient,$subject,$smtpserver)=@_;


@multipart = (
Email::MIME->create(
attributes => {
content_type => "text/plain",
format => "flowed",
charset => "US-ASCII",
},
body => $text,
),
Email::MIME->create(
attributes => {
content_type => "text/html",
charset => "US-ASCII",
encoding => "quoted-printable",
format => "flowed",
},
body => $html,
),
);


$email = Email::MIME->create(
header => [ From => $sender ],
parts => [ @multipart ],
);


$email->header_set( To => $recipient );
$email->header_set( Subject => $subject );
$email->header_set( 'Content-Type' => 'multipart/alternative' );
$email->boundary_set('INFOTEK_Boundary_text');


$mailer = Email::Send->new({mailer => 'SMTP'});
$mailer->mailer_args([Host => "$smtpserver"]);
$mailer->send($email);
}

Re: Send::Mail nothing happens and no errors

am 25.01.2007 17:28:08 von paduille.4060.mumia.w+nospam

On 01/25/2007 09:09 AM, Andy wrote:
> I'm using the perl module Email::Send to generate email. In my tests,
> the send function executes and no errors are thrown. But, even though
> I'm sending the email to myself through my local SMTP email server to
> my local exchange server, nothing seems to happen.
>

Although this newsgroup has nothing to do with comp.lang.perl.misc, it
benefits you to read the posting guidelines for that newsgroup:
http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines. html

Those guidelines have advice that would help you find your bug faster.

> I'm also using Email::MIME and Email::MIME::Creator to build the email
> headers.
>
>
> Does anyone have any suggestions on what is going wrong or how to
> diagnose the problem?
>
>
> I'm running PERL on a windows platform; here's the code I'm calling to
> send the email:
>
> use Email::MIME;
> use Email::MIME::Creator;
> use Email::Send qw:SMTP:;
>

Amongst other things, the posting guidelines for clpmisc advise you to
place "use strict;" and "use warnings;" at the top of your programs. You
then have to change the program to work under those conditions--which
often reveals the bug.

> SendEmail("test","test","anedza@prodigysys.com","anedza@prod igysys.com","test","127.0.0.1");
> [...]


--
Windows Vista and your freedom in conflict:
http://www.securityfocus.com/columnists/420/2

Re: Send::Mail nothing happens and no errors

am 25.01.2007 19:06:59 von Andy

I've added the strict and warnings, and the only thing they point out
is that the @ in my email address could be mistaken for an array. But,
I've tried both escaping and not escaping it.

The PERL script doesn't actually crash, it compiles and finishes
execution successfully without any errors (the last statement in the
script is a line to print the word "done", which appears in the
output).

I'm not very familiar with the Email::Send module. The problem may
have something to do with this module needing another email subsystem
that isn't present on my windows PC. Or, it maybe something to do with
having access to the SMTP server.

I've verified that the SMTP server we have doesn't require any
authentication.

I've also put in a dummy address to a non-existant SMTP server, and
Email::Send doesn't seem to crash. In either case, there is a
noticable pause before the single email is sent and the word "done"
appears.

The Email::Send documentation talks about the need to write a "mailer".
But, there are examples on the internet where the mailer is the SMTP
server itself. Do I need to write a mailer agent?

Any pointers or thoughts would be much appreciated....

Andy

Re: Send::Mail nothing happens and no errors

am 25.01.2007 20:51:15 von Mark Clements

Andy wrote:
> I've added the strict and warnings, and the only thing they point out
> is that the @ in my email address could be mistaken for an array. But,
> I've tried both escaping and not escaping it.
The code you've posted (as it stands) won't even compile under strict.
You won't find you get much help here until it does: strict catches so
many potential errors it often isn't worth even looking at a problem
unless it has been enabled.

> The PERL script doesn't actually crash, it compiles and finishes
> execution successfully without any errors (the last statement in the
> script is a line to print the word "done", which appears in the
> output).

What appears in the mail server logs? What is in the mail server queues?

What is the return value of

$mailer->send($email);

Check the docs for Email::Send::SMTP.

Have you tried sending a plain email without using Email::MIME?

Can you telnet to port 25 of the mail server and type SMTP to it directly?

Why are you using 127.0.0.1 as your smtp server? Is unlikely (although
possible) that your workstation is an smtp server.

Mark

Re: Send::Mail nothing happens and no errors

am 25.01.2007 21:59:32 von Andy

Thanks for the help...

You were right. Capturing the result from

$result=$mailer->send($email);

showed that "Can't send data" was returned.


Telneting into the IP address I was connecting Email::Send to with port
25 (using HyperTerminal on windows) showed a greeting that indicated I
telneted into an SMTP server on my PC, and not the SMTP server on our
network.

Andy

Re: Send::Mail nothing happens and no errors

am 25.01.2007 22:47:31 von paduille.4060.mumia.w+nospam

On 01/25/2007 12:06 PM, Andy wrote:
> I've added the strict and warnings, and the only thing they point out
> is that the @ in my email address could be mistaken for an array. But,
> I've tried both escaping and not escaping it.
>
> The PERL script doesn't actually crash, it compiles and finishes
> execution successfully without any errors (the last statement in the
> script is a line to print the word "done", which appears in the
> output).
>
> I'm not very familiar with the Email::Send module. The problem may
> have something to do with this module needing another email subsystem
> that isn't present on my windows PC. Or, it maybe something to do with
> having access to the SMTP server.
>
> I've verified that the SMTP server we have doesn't require any
> authentication.
>
> I've also put in a dummy address to a non-existant SMTP server, and
> Email::Send doesn't seem to crash. In either case, there is a
> noticable pause before the single email is sent and the word "done"
> appears.
>
> The Email::Send documentation talks about the need to write a "mailer".
> But, there are examples on the internet where the mailer is the SMTP
> server itself. Do I need to write a mailer agent?
>
> Any pointers or thoughts would be much appreciated....
>
> Andy
>

Most definitely you don't need to write a Mail Transport Agent (MTA). It
sounds like Email::Send (which I don't have) wants to write to sendmail
or exim.

Sendmail and exim are *nixy programs that probably have been ported to
Windows, but very few Windows users have them installed. Even if you
install Sendmail for Windows, you'd have to tell Email::Send about the
location of sendmail using whatever way the module allows for that.

Or you could dump Email::Send and use a module that specifically
advertises it's ability to talk SMTP to a configurable host and port (25
or 587).

Or if you install and configure sendmail, you could talk directly to
sendmail, bypassing Email::Send.


--
Windows Vista and your freedom in conflict:
http://www.badvista.org/