Regarding my question on Send email with recipient name, which has taken some time without response, i have came up with something like below, but its not working, even reporting any error.
#!/usr/bin/perl -wT use lib '.'; use strict; use warnings; use DBI; use Email::Sender::Simple qw(sendmail); use Email::Sender::Transport::SMTP (); use Email::Simple (); use Email::Simple::Creator (); use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); $CGI::DISABLE_UPLOADS = 1; $CGI::POST_MAX = 1048576; print "Content-type: text/html\n\n"; my $host = "host"; my $usr = "user"; my $pwd = "pwd"; my $dbname = "datname"; my $dbh = DBI->connect("DBI:mysql:$dbname:$host", $usr, $pwd, { RaiseError => 1, }) or die $DBI::errstr; my @names; my @rcpts; my $name; my $rcpt; my $Response; sub getusers { my $sth = $dbh->prepare("SELECT * FROM bmop"); $sth->execute(); while (my @row = $sth->fetchrow_array) { $name = $row[2]; # Get their names $rcpt = $row[5]; # Get their emails push @names,$name; push @rcpts,$rcpt; } } sub getready { my $j = 0; foreach my $i(@names){ ## Grab user info from the table $name = $names[$j]; # Get their name $rcpt = $rcpts[$j]; # Get their email sendmail(); $j++; } } sub sendmail { my $sub = "Test mail"; my $msg = "<p> Hi $name </p>"; my $smtpserver = 'smtp.xxxxxx.com'; my $smtpport = 587; my $smtpuser = 'dddddd'; my $smtppassword = 'ddddd'; my $transport = Email::Sender::Transport::SMTP->new({ host => $smtpserver, ssl => 'starttls', port => $smtpport, sasl_username => $smtpuser, sasl_password => $smtppassword, }); my $email = Email::Simple->create( header => [ To => $rcpt, From => 'xxx@xxxx.com', Subject => $sub, 'Content-Type' => 'text/html', ], body => $msg, ); sendmail($email, { transport => $transport }); $Response = "Process started"; }
In reply to mail with users names by frank1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |