#!/usr/local/bin/perl
print "Content type: text/html\n\n";
open (SENDMAIL, "¦ /usr/sbin/sendmail -t");
print SENDMAIL "Subject: Test BCC\n";
print SENDMAIL "To: $ENV{SERVER_ADMIN}\n";
print SENDMAIL "From: $ENV{SERVER_ADMIN}\n";
print SENDMAIL "BCC: bcc\@$ENV{SERVER_NAME}\n\n";
print SENDMAIL "http://$ENV{SERVER_NAME}\n\n";
close (SENDMAIL);
exit;
I would back track and double check your variables:
- set a variable eq to the environ emails you are trying to use: eg:
$ty=$ENV{SERVER_ADMIN}
Then echo that to the screen as you use them in the script.
if (-e $mailprog) {
open(MAIL, "¦$mailprog -t");
print MAIL "To: $emailadr\n";
print MAIL "Bcc: $ebcc\n";
print MAIL "From: $fromemail\n";
print MAIL "Subject: Bill The Cat - Ack!\n\n";
print MAIL "$message";
close(MAIL);
}
#!/usr/local/bin/perl
$mailprog = '/usr/sbin/sendmail';
$emailadr = 'to@mydomain.com';
$ebcc = 'bcc@mydomain.com';
$fromemail = 'from@mydomain.com';
$message = 'Test BCC';
if (-e $mailprog) {
open(MAIL, "¦$mailprog -t");
print MAIL "To: $emailadr\n";
print MAIL "Bcc: $ebcc\n";
print MAIL "From: $fromemail\n";
print MAIL "Subject: Test BCC\n\n";
print MAIL "$message";
close(MAIL);
}
print "Content type: text/html\n\n";
exit;
As you can see, each email address is different. I even ran the script twice and swapped the TO and BCC email addresses to make sure that they were both working (which they were) but still no BCC either way.
The only odd thing I noticed was that when I ran the script a third time and used TO and BCC email addresses that I know would bounce, I never got a bounce at the FROM even though I got one when I manually sent an email to the same invalid TO and BCC addresses using Outlook. Maybe that's normal for sendmail - I dunno - just thought maybe it would help all you headscratchers figure out who's to blame here.
Here's the deal:
When I send an email with a BCC to 5 different email addresses at some major domain that starts with a Y and provides web based email I get an email at each of the 5 accounts...
- but -
When I send an email with a BCC to 5 different email aliases at my own domain I only get 1.
Why?
Because they are not separate POP accounts like at the Y. They are all being forwarded to one account and somewhere along the line, the duplication gets filtered out.
I expected to get the 5 BCC's sent but in that scenario, getting just the 1 is actually more correct because there is only 1 physical account.
Granted, you guys couldn't see that and I couldn't either until I tried using completely separate domains.
The moral to be learned here is to make sure that your proposed test environment simulates the actual working environment as much as possble to eliminate the possibility of interpreting the results incorrectly.
The BCC was working all along - just not how I expected it to.
Special thanks to MichaelBluejay for suggesting separate domains which helped me resolve "the problem that wasn't"!