Forum Moderators: coopster & phranque

Message Too Old, No Replies

How do you send the same email to multiple recipients with Sendmail us

         

lisali

12:08 am on Nov 21, 2016 (gmt 0)



I have the following PERL script, but I can't seem to get it to send to more than one email at once. How do I send to multiple emails within the same script, preferably as separate emails, CC, BCC or just an additional TO:?

Thank you! :)


open(SENDMAIL, "|/usr/lib/sendmail -oi -t") || die "Cannot open sendmail output";

print SENDMAIL <<"ENDENDEND";
From: <test\@test.com>
To: <test1\@test1.com>
Subject: report spam
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="DeathToSpamDeathToSpamDeathToSpam"

This is a multi-part message in MIME format.
--DeathToSpamDeathToSpamDeathToSpam
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


--DeathToSpamDeathToSpamDeathToSpam
Content-Type: message/rfc822
Content-Disposition: attachment

ENDENDEND

while (<STDIN>) {
print SENDMAIL ;
}


print SENDMAIL <<"ENDENDEND";

--DeathToSpamDeathToSpamDeathToSpam--
ENDENDEND

close (SENDMAIL);

keyplyr

2:50 am on Nov 21, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi lisali welcome to WebmasterWorld [webmasterworld.com]

It's sometimes a little slow here on weekends, but someone helpful should come along soon.

phranque

9:49 am on Nov 21, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



did you try adding a Cc: header to your sendmail input?

you might want to consider using a perl library such as Email::Sender:
http://search.cpan.org/~rjbs/Email-Sender-1.300030/lib/Email/Sender.pm [search.cpan.org]

lisali

1:51 pm on Nov 21, 2016 (gmt 0)



Hi @keyplyr - thanks for the lovely welcome!

@phranque That seems to work, many thanks! For some reason, using Bcc: or adding another To: email does NOT work, but Cc: seems to do it.

Many thanks for your help, I really appreciate it! :)

Brett_Tabke

7:19 pm on Nov 21, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



When you add the To: separate the emails with a comma.
bill@cat.com,fred@dog.com,apple@badtree.com

Same with bcc.

$mailprog = "/usr/sbin/sendmail";
$message= "hi there";
$Subject= "Test ye old test";
open(MAIL, "|$mailprog -t");
print MAIL "To: sam\@iam.com\n";
print MAIL "bcc: jim\@example.com\n";
print MAIL "From: Test\@webmasterworld.com\n";
print MAIL "Subject: $subject\n\n";
print MAIL "$message";
close(MAIL);

phranque

12:32 am on Nov 22, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



oh and welcome to WebmasterWorld, lisali!

lisali

1:03 pm on Nov 22, 2016 (gmt 0)



Thank you for the tip, @brett_tabke! That's very helpful.

@phranque - Many thanks, what a friendly bunch here, it's so refreshing! :)