in reply to Unexpected 'newline' token breaks sendmail.

I can't say whether this contributes to your problem, but it is a problem: You're declaring sendemail() with an empty prototype. You're then calling it with arguments, but you're probably not getting a related warning because calling with the & ampersand (as in &mysub(args)) syntax silences prototype checking.

Your sub call should look like this instead:

sendemail( args );

And your sub declaration / definition should look like this:

sub sendemail { #code here }

Notice how parenthesis were excluded from the sub declaration.

More on this in perlsub. But the short of it is don't use prototypes.

Also, your code example makes it look almost like you're creating an object (my $self = {}), though it never gets blessed, and it's happening out in the open instead of isolated within a subroutine such as new() in a separate module. The 1; line also makes it look like you started by simply cutting code out of a module. Also, your sendemail() subroutine declares a "$self".... but what for if there's no object and it's not an object method?


Dave