Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Mail::Sendmail Module

by ytjPerl (Scribe)
on Feb 26, 2018 at 15:05 UTC ( [id://1209977]=perlquestion: print w/replies, xml ) Need Help??

ytjPerl has asked for the wisdom of the Perl Monks concerning the following question:

Hello Guys,

I have the below codes for sending mail through gmail server. I do not have syntax error executing it. but it is not working as expected. Please point out my errors. thanks

#!/usr/bin/perl use strict; use warnings; use Mail::Sendmail; my %mail; $mail{Smtp} = "smtp.gmail.com"; $mail{Debug} = 6; $mail{Port} = 465; $mail{Auth} = {user => "username", pass => "password", method => "LOGIN", required => 1}; # set the recipients (to) address [REQUIRED] $mail{To} = 'xxxxxxx@gmail.com'; # set the mail sender address [REQUIRED] $mail{From} = 'xxxxxxx@gmail.com'; $mail{Sender} = 'xxxxxxx@gmail.com'; # set the mail subject line $mail{subject} = "Test message"; # set the mail content $mail{body} = "The test messsage is having this body line inside."; # set the mail encoding type $mail{'content-type'} = qq(text/plain; charset="utf-8");

2018-02-27 Athanasius fixed opening code tag and added paragraph tags

Replies are listed 'Best First'.
Re: Mail::Sendmail Module
by toolic (Bishop) on Feb 26, 2018 at 15:23 UTC
    • Edit your post to fix the leading "code" tag so people can easily read your question.
    • Read The Fine Manual for Mail::Sendmail. All your code does is set the %mail hash variable. You need to call the sendmail function.
    sendmail(%mail) or die $Mail::Sendmail::error;
      Thanks! I got those errors when I call the send:mail Use of uninitialized value $_ in concatenation (.) or string at C:/Perl64/site/l ib/Mail/Sendmail.pm line 215. Use of uninitialized value $_ in pattern match (m//) at C:/Perl64/site/lib/Mail/ Sendmail.pm line 218. Use of uninitialized value $_ in concatenation (.) or string at C:/Perl64/site/l ib/Mail/Sendmail.pm line 401. ERROR
        Hi ytjPerl,

        you've been asked by toolic to edit your original post and fix the leading code tag (i.e. change it to <code>), and you did not, although you've obviously read toolic's post, since you replied to it. Why don't you fix your post? Don't you see it is very difficult to read? Do yourself a favor: if you want additional good answers, make it easy for other monks here to read your post: fix it.

        And, BTW, please also edit your reply above and put the warnings and error messages between <code> and </code> tags.

Re: Mail::Sendmail Module
by hippo (Bishop) on Feb 26, 2018 at 16:19 UTC
    $mail{Auth} = {user => "username", pass => "password", method => "LOGIN", required => 1};

    This will have no effect. There is no "Auth" key mentioned anywhere in the documentation which specifically says "No suport (sic) for the SMTP AUTH extension". If you need this, consider some other module.

    Update: As toolic says in the reply below there is now an "Auth" key in version 0.80 although the doc says the support is experimental. YMMV.

      This will have no effect. There is no "Auth" key mentioned anywhere in the documentation
      Are you sure? The POD does not explicitly show $mail{Auth}, but it states:
      Keys are NOT case-sensitive.

      I see this in the sendmail code:

      # arrange keys case $k = ucfirst lc($k);

      I have a feeling that $mail{Auth} is the same as $mail{auth}.

        Well it turns out that you are quite right. There has been a new release of Mail::Sendmail which adds "auth" as a field and is the first stable release in some 15 years (v0.80 has the auth field, v0.79 doesn't). That will teach me to assume it was abandoned.

        The comment in the docs now says "Experimental SMTP AUTH support (LOGIN PLAIN CRAM-MD5 DIGEST-MD5)", so that's the progress. Thanks for the heads-up.

      what other module do you recommend? I have been told this was the latest updated one.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1209977]
Approved by toolic
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-25 05:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found