Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello Monks :) I have a question. I am not so familiar with perl, thus I need a little help. I have a small business and I've found a script to send buletin to my customers (~180 costumers), the script working awesome, but it doesn't has SMTP authentication. The headers of received mail looks terible, also some of my clents are unable to receive them. I am using recent centos + cpanel, I have created email account and SMTP settings, thus could you please help me to modify this script for better working. Here is the script:
#!/usr/bin/perl -w #user configuration begin# $mailprg = "/usr/sbin/sendmail"; #path to your mail program $delay = 0.25; #delay in seconds $from = 'Coname<somename@domain.com>'; #from address in your m +ail $subject = 'Trial send'; #subject of newsletter. u can add + the spl code $USERNAME$ $maildata = "mail.dat"; #mail address file $msgtemplate = "message.template"; #message template file #user configuration end# if(@ARGV){ $i = 0; while($ARGV[$i]){ if($ARGV[$i] eq "--help"){ print "Command Line Options:\n\n"; print "-t\tTest how the message will be formatted\n"; print "-d\tData file listing the email addresses\n"; print "-m\tMessage template file\n"; print "-s\tSubject\n"; print "-f\tFrom address. Quote for security reasons\n"; die "\nMore information at indiWiz.com\n"; } elsif($ARGV[$i]=~/^-/){ $arr = substr($ARGV[$i],1,1); if($arr eq "d"){ $maildata = $ARGV[$i+1]; $i+=2; } elsif($arr eq "m"){ $msgtemplate = $ARGV[$i+1]; $i+=2; } elsif($arr eq "t"){ $testflag = 1; $i++; } elsif($arr eq "s"){ $subject = $ARGV[$i+1]; $i+=2; } elsif($arr eq "f"){ $from = $ARGV[$i+1]; $i+=2; } else{ die "Wrong argument!"; } } } } open TEMPLATE, $msgtemplate || die "Cannot open template file!\n"; while(<TEMPLATE>){ $msg .= $_; } close TEMPLATE || die "Cannot close template file!\n"; open MAILFILE,"$maildata" || die "Cannot open data file!\n"; while(<MAILFILE>){ chomp($_); @arr = split(/\@/,$_); $arr[0] = ucfirst($arr[0]); $tmp = $msg; $tmp =~ s/\$USERNAME\$/$arr[0]/g; $subject =~ s/\$USERNAME\$/$arr[0]/g; $temp = "To: $arr[0]<$_>\n"; $temp .= "From: $from\n"; $temp .= "Subject: $subject\n\n\n"; $temp .= $tmp; if($testflag){ print $temp; last; } else{ open MAILPRG,"|$mailprg -t" || die "Cannot open mail program!\ +n"; print MAILPRG $temp; close MAILPRG || die "Cannot close mailprogram!\n"; if($delay < 0){ $delay = 1; sleep $delay; } elsif($delay < 1){ select(undef,undef,undef,$delay); } else{ sleep $delay; } print $_,"\n"; } } close MAILFILE || die "Cannot close data file!\n";
All I need to not use sendmail and just a written mail, I need to authenticate to SMTP with mail SMTP settings and send those mails properly. Thank you and sorry for my english.

In reply to SMTP authentication by voner

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-16 12:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found