Platinum Partner

Simple Command-line Mailinglist

This code reads an email-list stored in the file"emailist.txt".
This file contains all adresses delimited by "\n", i.e.
one column of emails. However, you have to have sendmail installed.


#!/usr/bin/perl
#
#	Mailing-List.pl
#	2005 by Sascha Tayefeh
#	http://www.tayefeh.de
#
#	This code reads an email-list stored in a file:	emailist.txt
#	This file contains all adresses delimited by \n, i.e.
#	one column of emails.
#

use strict;

my ($absender, $empfaenger, $betreff, $body, $content,$file,$line,$i,$k);
my (@line,@liste);

$file="./emailist.txt"; # a one-column textfile providing the emails (one per line)
#$empfaenger = "singleReceiver\@singleReceiver.single"; # E-mail of a single-receiver
$absender = "sender\@sendersEmail.sender>"; # E-mail of the sender
$betreff = "Header here"; # header of the email
$body = "\nThis is the body of the messag \n\n Bye\n"; # The message body


$line[0]= sprintf("From: %s \n",$absender);
$line[1]= sprintf("To: %s \n",$empfaenger);
$line[2]= sprintf("Subject: %s \n",$betreff);
$line[3]= sprintf("%s \n",$body);

$i=0;
open(LIST, $file);
while (defined ($line=)) {
    chomp $line;
    $liste[$i] = $line;
    $i++;
}
close(LIST);

print $body;

printf("%d emails to sent\n",$i);

for ($k=0; $k<$i; $k++) {
    open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq") or die "fork fuer sendmail fehlgeschlagen: $!\n";
    $line[1]= sprintf("TO: %s \n",$liste[$k]);
    printf("Sending mail %d to %s\n",$k+1,$liste[$k]);
    foreach $content (@line) {
	print SENDMAIL $content;
    }
    close(SENDMAIL) or warn "sendmail wurde nicht recht beendet...";
    sleep 1;
}

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}