Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PERL NET::SMTP Cc Bcc Help Needed

Posted on 2004-11-22
1
Medium Priority
?
16,850 Views
Last Modified: 2013-12-25
Ok, I know how to use Net::SMTP to send messages with a single recipient but I am having problems using $smtp->bcc(). I want to send to multiple recipients in the bcc field. I have tried variables and arrays but nothing seems to work.

A side note: some addresses are not delivered to. i.e. the mail sent from my script is never received. Any ideas where I should start to look?

my $ServerName = $smtpserver;
$smtp = Net::SMTP->new($ServerName, Debug => 0);

$smtp->mail( $from );
$smtp->to( $to );

$smtp->data();
$smtp->datasend("To:  $to\n");
$smtp->datasend("From:  $from\n");
$smtp->datasend("Date: $mdate\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-type: text/html\n");
$smtp->datasend("Content-Transfer-Encoding: 7bit\n");
$smtp->datasend("\n");
$smtp->datasend("$msg\n\n");
$smtp->dataend();
$smtp->quit();
0
Comment
Question by:Bob-Villa
1 Comment
 
LVL 2

Accepted Solution

by:
revantine earned 375 total points
ID: 12644440
This is from a script I use for automated invoicing. It emails the client and bcc's to myself. The syntax below is from the notes I made from my programming and testing senarios. Although I only BCC myself, I would not have left the note in place if it didn't work when I tested.

   $smtp->mail($from);
   $smtp->to($to);
   $smtp->bcc($bcc, $anotherbcc, $onemorebcc);
   # to ( ADDRESS [, ADDRESS [...]] )
   # cc ( ADDRESS [, ADDRESS [...]] )
   # bcc ( ADDRESS [, ADDRESS [...]] )
   $smtp->data();

   $smtp->datasend("From: $from\n");
   $smtp->datasend("To: $to\n");
# build a subject string
   $SUBJECT="An email from us";
   $smtp->datasend("Subject: ".$SUBJECT."\n");
   $smtp->datasend("MIME-Version: 1.0\n");
   $smtp->datasend("Content-Type: text/html; charset=us-ascii\n");
   $smtp->datasend("\n");

   $smtp->datasend("Hope you are well.\n");
   $smtp->datasend("Have fun for the holidays\n");
   $smtp->datasend("Revantine\n");

   # dataend
   $smtp->dataend();    # NOT datasend!
   $smtp->quit;

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month20 days, 15 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question