Hi!
I was a little bit puzzled about all 10 days sending the "what's new"-mails manualy. Most the time, I forgot about it. So I did a little script to run per cron. It's not yet testet very well, and it's at all nothing special, just some drag'n'drop from different links-sources. Have a look at it, and send bug-reports and sugestions.
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \
require 5.001; # Make sure we have at least perl 5.001.
require "links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/links.def"; # Database Definitions
require "$db_lib_path/db.pl"; # Database Routines.
require "$db_lib_path/db_utils.pl"; # Database Support utilities.
require "$db_lib_path/Mailer.pm"; # Mailing Routines
};
# edit this part for translation or better text
my $cfg_title = "What's new " . &get_date();
my $cfg_mail_footer = qq|--------------------------------------------------------------------
To unsubscribe from this mailing list, just visit:
$build_email_url?action=unsubscribe&email=<%Contact Email%>|;
# nothing to edit under this line
&main();
sub main{
my $message = &build_new_links . $cfg_mail_footer;
my $subscribers = &build_email_list;
my $subject = $cfg_title;
my $start = time();
print qq|Mailing started on |, scalar localtime($start), "\n";
# Make sure we have everything we need.
my %seen;
$message =~ s/\r//g;
$message or (print "No message defined! Aborting!" and exit);
$subject or (print "No subject defined! Aborting!" and exit);
$db_admin_email or
(print "An admin email has not been set in the config. Aborting!" and exit);
($db_smtp_server or $db_mail_path) or
(print "No SMTP server or Sendmail has been defiend in the config. Aborting!" and exit);
# Let's initilize a mailer.
my $mailer = new Mailer ( { smtp => $db_smtp_server, sendmail => $db_mail_path,
from => $db_admin_email, subject => $subject,
msg => $message,
log => $db_mailer_log } ) or &cgierr("Unable to init mailer! Reeason: $Mailer::error");
print qq~
Mailing Message:
--------------------------------------------------------
From: $db_admin_email
Subject: $subject
$message
--------------------------------------------------------
~;
# And begin mailing!
my ($email_q, $email_n, $href, $msg_mod);
open (DB, "<$db_email_name ") or &cgierr("unable to open db file: $db_email_name .\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
($email, $name) = split /\Q$db_delim\E/;
$email_q = &urlencode ($email);
# Make sure the address looks ok, and we haven't already mailed to this email address.
($email =~ /.+@.+\..+/) or (print qq~Invalid email address: '$email'. Skipping.\n~ and next);
($seen{$email}++) and (print qq~Already mailed to: '$email'!\n~ and next);
$msg_mod = &load_template('email', { 'Contact Email' => $email }, $message);
$mailer->send ( { to => $email, msg => $msg_mod } ) ?
(print qq~Message sent succesfully to '$email'\n~) :
(print qq~Unable to mail to '$email'. Reason: $Mailer::error\n~);
} # end of while
# All done, print summary stats.
my $finish = time();
my $elapsed = $finish - $start;
print "--------------------------------------------------------\n";
print "Mailing finished at: ", scalar localtime($finish), ".\nElapsed: $elapsed s.\n";
close DB;
} # end of mainBye
Tiggr
I was a little bit puzzled about all 10 days sending the "what's new"-mails manualy. Most the time, I forgot about it. So I did a little script to run per cron. It's not yet testet very well, and it's at all nothing special, just some drag'n'drop from different links-sources. Have a look at it, and send bug-reports and sugestions.
Code:
#!/usr/bin/perl eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \
require 5.001; # Make sure we have at least perl 5.001.
require "links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/links.def"; # Database Definitions
require "$db_lib_path/db.pl"; # Database Routines.
require "$db_lib_path/db_utils.pl"; # Database Support utilities.
require "$db_lib_path/Mailer.pm"; # Mailing Routines
};
# edit this part for translation or better text
my $cfg_title = "What's new " . &get_date();
my $cfg_mail_footer = qq|--------------------------------------------------------------------
To unsubscribe from this mailing list, just visit:
$build_email_url?action=unsubscribe&email=<%Contact Email%>|;
# nothing to edit under this line
&main();
sub main{
my $message = &build_new_links . $cfg_mail_footer;
my $subscribers = &build_email_list;
my $subject = $cfg_title;
my $start = time();
print qq|Mailing started on |, scalar localtime($start), "\n";
# Make sure we have everything we need.
my %seen;
$message =~ s/\r//g;
$message or (print "No message defined! Aborting!" and exit);
$subject or (print "No subject defined! Aborting!" and exit);
$db_admin_email or
(print "An admin email has not been set in the config. Aborting!" and exit);
($db_smtp_server or $db_mail_path) or
(print "No SMTP server or Sendmail has been defiend in the config. Aborting!" and exit);
# Let's initilize a mailer.
my $mailer = new Mailer ( { smtp => $db_smtp_server, sendmail => $db_mail_path,
from => $db_admin_email, subject => $subject,
msg => $message,
log => $db_mailer_log } ) or &cgierr("Unable to init mailer! Reeason: $Mailer::error");
print qq~
Mailing Message:
--------------------------------------------------------
From: $db_admin_email
Subject: $subject
$message
--------------------------------------------------------
~;
# And begin mailing!
my ($email_q, $email_n, $href, $msg_mod);
open (DB, "<$db_email_name ") or &cgierr("unable to open db file: $db_email_name .\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
($email, $name) = split /\Q$db_delim\E/;
$email_q = &urlencode ($email);
# Make sure the address looks ok, and we haven't already mailed to this email address.
($email =~ /.+@.+\..+/) or (print qq~Invalid email address: '$email'. Skipping.\n~ and next);
($seen{$email}++) and (print qq~Already mailed to: '$email'!\n~ and next);
$msg_mod = &load_template('email', { 'Contact Email' => $email }, $message);
$mailer->send ( { to => $email, msg => $msg_mod } ) ?
(print qq~Message sent succesfully to '$email'\n~) :
(print qq~Unable to mail to '$email'. Reason: $Mailer::error\n~);
} # end of while
# All done, print summary stats.
my $finish = time();
my $elapsed = $finish - $start;
print "--------------------------------------------------------\n";
print "Mailing finished at: ", scalar localtime($finish), ".\nElapsed: $elapsed s.\n";
close DB;
} # end of main
Tiggr