Google Answers Logo
View Question
 
Q: Can't get Bcc to work in a Perl script - for webadept-ga only - re q.id#254362 ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Can't get Bcc to work in a Perl script - for webadept-ga only - re q.id#254362
Category: Computers > Programming
Asked by: horseradish-ga
List Price: $5.00
Posted: 11 Sep 2003 14:28 PDT
Expires: 11 Oct 2003 14:28 PDT
Question ID: 254760
I closed the question, not realising you hadn't answered, but 'asked
for clarification', so you didn't get paid! The answer you gave in
that was fine and now it works, thank you veyr much! If you answer
this you should get your fee this time.
Answer  
Subject: Re: Can't get Bcc to work in a Perl script - for webadept-ga only - re q.id#254362
Answered By: webadept-ga on 11 Sep 2003 17:14 PDT
Rated:5 out of 5 stars
 
I'm glad to hear that the solution worked for you. Really wasn't
looking forward to messing with the sendmail config files. :-)

Good luck in your future coding. 

One thing, I have an object I use for sending mail, which uses
sendmail, and can do attachments and everything else. If you would be
interested in a copy of that, just post a clarification to this
question and I'll post it for you here.

webadept-ga

Request for Answer Clarification by horseradish-ga on 12 Sep 2003 00:58 PDT
Ok, thanks very much :-)

Clarification of Answer by webadept-ga on 12 Sep 2003 02:14 PDT
Hi, 

this setup using Mail::Sender doesn't require that the sendmail server be 
on the computer you are sending the mail from. It is a rather unique mail 
sending mod. I encourage you to check it out if you are going to be doing 
any real mail programming. 

The $file can be anything from plain text to html text. Your choice. 

You can find out more about this mod at :
http://jenda.krynicky.cz/perl/Sender.pm.html



#! /usr/local/bin/perl -w

use strict;
use Mail::Sender;

 my $recipients = 'test\@yourhost.com';
 my $subject = 'What ever';

 my $from = 'me\@yourhost.com';
 my $url = '127.0.0.1'; # your host IP here; 

 $in = 'myHTML.txt';
 my $file = "";
 open(IN, "$in") or die "failed to open text message : $!";
 while(<IN>)
  {
     $file .= $_;
  }
close IN;
    
 &sendmail($recipients, $subject, $from, $url, $file);
 

#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#

sub sendmail
{
 my $recipients = shift;
 my $subject = shift;
 my $from = shift;
 my $url = shift;

 my $file = shift;
 
 my $time = time;
 $time = rand($time);
 
 

   
	my $sender = new Mail::Sender {smtp => $url};
        if (ref $sender->OpenMultipart({
                from => $from, 
		to => $recipients,
                subject => $subject,
                boundary => 'boundary--'.$time,
                type => 'multipart/related'})) {
                $sender->Attach(
                         {description => 'html body',
                         ctype => 'text/html; charset=us-ascii',
                         encoding => '7bit',
                         disposition => 'NONE',
                         file => $file
                });
                
		$sender->Close() or die "Close failed! $Mail::Sender::Error\n";
        } else {
                die "Cannot send mail: $Mail::Sender::Error\n";
        }


}
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#


have a good time and good luck in your future Perl code. 

webadept-ga
horseradish-ga rated this answer:5 out of 5 stars

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy