in reply to mail with users names

Crossposted to StackOverflow.

Crossposting is allowed, but it's considered polite to announce it to prevent people not visiting both sites from hacking on a problem already solved at the other end of the internet.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: mail with users names
by marto (Cardinal) on Jan 04, 2024 at 16:44 UTC
Re^2: mail with users names
by frank1 (Monk) on Jan 06, 2024 at 18:19 UTC

    i have fixed my script and working very well now. without any help from anyone. i just went through each sub function to make sure each works

    wat was confusing me is that. i thought i can just call only 1 function and leave others behind and run themselves on script execution

    Now my mine point is to work on this script efficacy and effective to deliver msg to over 100k receivers

    Anyone want to addone something, so it become more effective on delivering msg to 100k, i appreciate

    #!/usr/bin/perl -wT use lib '.'; 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 = "xxxxx"; my $usr = "xxxxx"; my $pwd = "xxxxx"; my $dbname = "xxxxx"; my $dbh = DBI->connect("DBI:mysql:$dbname:$host", $usr, $pwd, { RaiseError => 1, }) or die $DBI::errstr; 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; } } getusers(); sub getready { my $j = 0; foreach my $i(@names){ ## Grab user info from the table $rcv_names = $names[$j]; # Get their name $rcv_emails = $rcpts[$j]; # Get their email mail(); $j++; } } getready(); sub mail { my $sub = "Test mail"; my $msg = "<p> Hi $rcv_names </p>"; my $smtpserver = 'xxxx'; my $smtpport = 587; my $smtpuser = 'xxxxx'; my $smtppassword = 'x+x+x+'; 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 => $rcv_emails, From => 'xxxxx@xxxxx.com', Subject => $sub, 'Content-Type' => 'text/html', ], body => $msg, ); sendmail($email, { transport => $transport }); }