1). I need help with sending emails with their names in email body
2). Can i just loop to make sure each recipient gets email or Sub is enough. to send to over 100k emails
DB ID name email 1 jane test@test.com 2 tom tom@tom.com
my $msg = "Hello 'name' welcome to earth"; my $query = $dbh->prepare("SELECT DISTINCT email FROM users"); $query->execute(); my $records = $query->fetchall_arrayref; my @to; for my $em ( @$records ) { push @to, @$em; } for my $recipient(@to) { mail($recipient); } sub mail { my $recipient = shift; my $smtpserver = 'smtp.dddd.com'; my $smtpport = 587; my $smtpuser = ''; my $smtppassword = ''; 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 => $recipient, From => 'dddd@ddd.com', Subject => $sub, 'Content-Type' => 'text/html', ], body => $msg, ); sendmail($email, { transport => $transport }); my $Response = "Success!"; }
In reply to Send email with recipient name by frank1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |