http://www.perlmonks.org?node_id=951306

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

Hi everyone,

I know there are a some threads about sending an email on Windows but those are focused for people that use ActivePerl, but in my case I build Perl from the source.

I have installed:

MIME::Lite

MIME::Lite::TT::HTML

I know that my error comes from not setting correctly the host server, but this is exactly what I don't understand.

From what I have seen in the other threads, marvelous Linux works fairly easy with an application called sendmail.exe. But there is not such a thing on Windows. Supposedly by having installed Net::SMTP, whichever MIME::Lite will use as default and would work without any problem. But still it does not work for me.

I have tried the following without success:

MIME::Lite->send( "smtp", "smtp.gmail.com", Timeout=>30, AuthUser=>"i_am_serious@gmail.com", AuthPass=>"whatApassword" );

So, if there anyone with a clue of what am I doing wrong here, I will appreciate your input. Also, if there is someone who can explain me a little bit about this host that has to be set? for example in Linux there is this application that works for sending emails but in Windows you need a server?, definitely, I really don't understand this mess, I'm quite confused.

Thanks

Replies are listed 'Best First'.
Re: Sending email on a Windows enviroment not using ActivePerl or StrawberryPerl
by chessgui (Scribe) on Feb 02, 2012 at 07:14 UTC
    I have a working solution on Win32 to send mail via SMTP which is only reliant on Net::SMTP and MIME::Base64. Takes care of authorization. It is very low level (does things like $smtp->datasend("AUTH LOGIN\n");), still if you are interested I can bring it to a readable shape.
      Thanks and yes would like to try your solution.
        I had to do the login in this manual way because I had problems with the authentication (the method provided by the SMTP object simply did not work: I did some research and turned out that others are having similar problems on Win32). My original code has hard coded server and user names. Now I've tried to comprise things in one sub called 'sendmail'. I've tested this sub to the extent of sending one e-mail and it worked. The parameters to the sub should be obvious (set 'debug' to '0' if everything works fine, set it to '1' and you will get a verbose debug info with the commands the SMTP object sends to the server and the responses - in my case this proved to be very helpful):
        use Net::SMTP; use MIME::Base64; # usage: sendmail(mailserver,username,password,from,to,subject,content +,debug); sub sendmail { my ($mail_server,$username,$password,$from,$to,$subject,$content,$debu +g)=@_; $smtp = Net::SMTP->new( $mail_server, Timeout => 30, Debug => $debug, ); $smtp->datasend("AUTH LOGIN\n"); $smtp->response(); $smtp->datasend(encode_base64($username)); $smtp->response(); $smtp->datasend(encode_base64($password)); $smtp->response(); $smtp->mail($from); $smtp->to($to); $smtp->data(); $smtp->datasend("To: $to\n"); $smtp->datasend("From: $from\n"); $smtp->datasend("Content-Type: text/html\n"); $smtp->datasend("Subject: $subject"); $smtp->datasend("\n"); $smtp->datasend($content); $smtp->datasend("\n"); $smtp->dataend(); $smtp->quit; }
Re: Sending email on a Windows enviroment not using ActivePerl or StrawberryPerl
by Anonymous Monk on Feb 02, 2012 at 03:33 UTC

    I know there are a some threads about sending an email on Windows but those are focused for people that use ActivePerl, but in my case I build Perl from the source.

    You should study those threads, they apply to you as well, perl is perl

      Well, I did study them, I did try their solutions and one of those I mentioned above with out success. Since networking is not my specialty and the only thing I need is just to send a email with or without attachments, so I was just looking for help on what I may be doing wrong or what am I missing with my configuration from someone who has experience in this field.