Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Sending email Help!

by Anonymous Monk
on Jan 02, 2013 at 02:31 UTC ( #1011198=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi there Monks!
All I am trying to do here is to send an HTML email, but I cant see where the problem is that no email gets sent. Here is some of the code I am using:
#!/usr/bin/perl use strict; use warnings; use autodie qw(open close); use CGI qw(-oldstyle_urls :standard); use CGI::Carp qw(fatalsToBrowser); use MIME::Lite; use POSIX qw/strftime/; my $date = strftime "%m/%d/%Y", localtime; print header(); send_reg_email( first_name => 'Joe', last_name => 'Doe', ); sub send_reg_email { my (%args) = @_; my $first_name = $args{first_name} || ''; my $last_name = $args{last_name} || ''; my $e_from = 'Form Registration <myemail@test.com>'; my $e_to = 'Form Support <myemail@test.com>'; my $msg = MIME::Lite->new( From => $e_from, To => $e_to, Subject => "Registration", Type => 'multipart/related') or die "Error Creating Message +: $!\n"; $msg->attach( Type => 'text/html', Data => qq| <html> <head> <meta http-equiv="Content-language" content="en-gb" /> <title>Registration Email</title> <style type="text/css"> html { margin:0; padding:0; } body { padding:0px 0px 0px 0px; margin:0px 0px 0px 0px; font-family:arial,helvetica; font-size: 14px; color:#808080; } .etext { font-family:arial,helvetica; font-size: 14px; color:#A1A1A1; } </style> </head> <body bgcolor="#1A1A1A"> <table width="100%" border="0" bgcolor="#1A1A1A" cellpaddin +g="0" cellspacing="0"> <tr> <td bgcolor="#1A1A1A" width="100%"> <table width="100%" border="1" bgcolor="#1A1A1A" cellp +adding="0" cellspacing="0"> <tr> <td bgcolor="#1A1A1A" width="125" height="47"><im +g src="cid:logo" width="212" height="98" border="0" /> </td> </tr> </table> </td> </tr> <tr> <td align="left"> <table width="100%" border="0" bgcolor="#1A1A1A" cell +padding="0" cellspacing="0"> <tr> <td bgcolor="#1A1A1A" width="100%" height="" align +="left">&nbsp;</td> </tr> <tr> <td bgcolor="#1A1A1A" width="100%" height="" align +="left"><div class="etext">&nbsp;&nbsp;<font color="#A1A1A1">Registra +tion Information</font></div></td> </tr> <tr> <td bgcolor="#1A1A1A" width="100%" height="" align +="left">&nbsp;</td> </tr> <tr> <td bgcolor="#1A1A1A" width="100%" height="" align +="left"><div class="etext">&nbsp;&nbsp;<font color="#A1A1A1">Name: $f +irst_name $last_name</font></div></td> </tr> <tr> <td bgcolor="#1A1A1A" width="100%" height="" align +="left">&nbsp;</td> </tr> <tr> <td bgcolor="#1A1A1A" width="100%" height="" align +="left">&nbsp;</td> </tr> </table> </td> </tr> <tr> <td align="left">&nbsp;</td> </tr> </table> </body> </html> |, ); # Attach GIF image $msg->attach( Type => 'image/png', Id => 'logo', Encoding => 'base64', Path => '../images/logo.png'); $msg->send(); } # end mail sub print "<br>DONE<br>";
Thanks for looking!

Comment on Sending email Help!
Download Code
Re: Sending email Help!
by Anonymous Monk on Jan 02, 2013 at 04:17 UTC

    While I can tell for sure where or what the problem is checking through your codes, I think you will do tell to heed the warning of this module's current maintainer MIME::Lite WAIT!
    Secondly, this

    my $first_name = $args{first_name} || ''; my $last_name = $args{last_name} || '';
    in your code, will perhaps be better written as
    my $first_name = $args{first_name} // ''; my $last_name = $args{last_name} // '';

      in your code, will perhaps be better written as

      No it won't

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1011198]
Approved by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-10-25 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (149 votes), past polls