CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
sendmail problems with more than 2 recipients

 



PGScooter
stranger

Feb 20, 2007, 1:45 AM

Post #1 of 13 (1454 views)
sendmail problems with more than 2 recipients Can't Post

Whenever I try to send an email to more than 2 recipients, it fails. The code below works for 2 users, but I can't seem to add on a third. If I try to add a semicolon after $friend2 and put $friend3 it doesn't work, and if I try to add on a
print MAIL "Bcc: $friend3\n"; it doesn't work either.

Any ideas?

Thanks.


Code
my $comments = "You have been challenged!"; 
open ( MAIL, "| /usr/lib/sendmail -t" );
print MAIL "From: $email\n";
print MAIL "To: $friend1;$friend2\n";
print MAIL "Subject: Name's Goal!\n\n";
print MAIL "$comments\n\n";
close ( MAIL );

The more you teach me, the more I learn. The more I learn, the more I teach.


KevinR
Veteran


Feb 20, 2007, 2:58 PM

Post #2 of 13 (1441 views)
Re: [PGScooter] sendmail problems with more than 2 recipients [In reply to] Can't Post

what are the values of $friend1, $friend2, $friend3, etc....
-------------------------------------------------


PGScooter
stranger

Feb 20, 2007, 6:01 PM

Post #3 of 13 (1436 views)
Re: [KevinR] sendmail problems with more than 2 recipients [In reply to] Can't Post

these values are inputted from an html form. I've done a check (printing to a file) to make sure that they are what they should be right before they are piped to sendmail, and they are indeed correctly inputted.

Sample values are:
$email='PGScooter@hotmail.com';
$friend1='email1@gmail.com';
$friend2='emailB@hotmail.com';
$friend3='emailX@gmail.com';


more complete code:

Code
$query=new CGI; 

$goal=$query->param('goal');
$goaltitle=$query->param('goaltitle');
$smonth=$query->param('smonth');
$sday=$query->param('sday');
$syear=$query->param('syear');
$emonth=$query->param('emonth');
$eday=$query->param('eday');
$eyear=$query->param('eyear');
##use goal title as name of goal file, must check first to see if it ##exists... make a required field##
###turn email into lower case###
###THEN, check to see if email already exists###
$type=$query->param('type');
$email=$query->param('email2');
$theemail="$email";
$amount=$query->param('amount');

$organization=$query->param('organization');
$public=$query->param('public');

$friend1=$query->param('friend1');
$friend2=$query->param('friend2');
$friend3=$query->param('friend3');

my $comments = "$friend1,$friend2,$friend3 Hi, I've decided to make a personal goal for myself and wanted to share it with you. Here are the details of my goal: $goal";
open ( MAIL, "| /usr/lib/sendmail -t" );
print MAIL "From: $email\n";
print MAIL "To: $friend1;$friend2\n";
print MAIL "Subject: Name's Goal!\n\n";
print MAIL "$comments\n\n";
#print MAIL "\n.\n";
close ( MAIL );

The more you teach me, the more I learn. The more I learn, the more I teach.


KevinR
Veteran


Feb 20, 2007, 8:48 PM

Post #4 of 13 (1431 views)
Re: [PGScooter] sendmail problems with more than 2 recipients [In reply to] Can't Post

not sure if this works or not:


Code
open ( MAIL, "| /usr/lib/sendmail $friend1,$friend2,$friend3 -t" ) or die "$!";


you may need to use quotemeta() on the variables first:


Code
$f1 = quotemeta($friend1); 
#etc
#etc


open ( MAIL, "| /usr/lib/sendmail $f1,$f2,$f3 -t" ) or die "$!";

-------------------------------------------------


PGScooter
stranger

Feb 21, 2007, 11:54 PM

Post #5 of 13 (1423 views)
Re: [KevinR] sendmail problems with more than 2 recipients [In reply to] Can't Post

Thanks for the help Kevin. However, now I can't even get the exact same script I was using for 1 and 2 emails to work. I'm going to send my webhost (netfirms) an email and see what they have to say.

I'll try your suggestions once I get that figured out.
The more you teach me, the more I learn. The more I learn, the more I teach.


ProBulletin
Novice

Feb 22, 2007, 2:19 AM

Post #6 of 13 (1418 views)
Re: [KevinR] sendmail problems with more than 2 recipients [In reply to] Can't Post

Why do you think quotemeta would help?


Regards,
Paul Wilson
ProBulletin Board: http://www.probulletin.com/


KevinR
Veteran


Feb 22, 2007, 10:43 AM

Post #7 of 13 (1414 views)
Re: [ProBulletin] sendmail problems with more than 2 recipients [In reply to] Can't Post

honestly I am not sure quotemeta would or would not help. I am just throwing out suggestions in hopes something might help. The concern is a meta character injected into the sendmail pipe might mess things up or even be insecure in some way I am not aware of. So better to play safe and escape any meta characters that might be present. At the least I would think the @ symbol needs escaping, but I am not even sure you can use them in the manner I suggested, or if it has to be aliases instead.

Do you have some thoughts on the matter or suggestions?
-------------------------------------------------


ProBulletin
Novice

Feb 22, 2007, 4:24 PM

Post #8 of 13 (1409 views)
Re: [KevinR] sendmail problems with more than 2 recipients [In reply to] Can't Post

The following works as expected for me:


Code
open MAIL, "|/usr/sbin/sendmail -t" or die "Error sending mail: $!"; 
print MAIL "To: paul\@xxx.com, admin\@xxx.com, postmaster\@xxx.com\n";
print MAIL "From: paul\@xxx.com\n";
print MAIL "Subject: Hello\n\n";
print MAIL "OK\n";
close MAIL;



Regards,
Paul Wilson
ProBulletin Board: http://www.probulletin.com/


KevinR
Veteran


Feb 22, 2007, 6:19 PM

Post #9 of 13 (1405 views)
Re: [ProBulletin] sendmail problems with more than 2 recipients [In reply to] Can't Post

that works for me too, I'm wondering if netfirms is limiting the number of emails that can be sent. Netfirms is a bit of an odd bird, at least they used to be. I haven't run into anyone using them for a while now but there used to be lots of issues with running scripts on their servers for reasons I can't recall now.
-------------------------------------------------


PGScooter
stranger

Feb 23, 2007, 3:43 PM

Post #10 of 13 (1397 views)
Re: [KevinR] sendmail problems with more than 2 recipients [In reply to] Can't Post

I tried your script ProBulletin and it didn't work. Your suspicion was correct Kevin; they sent me an email saying:

"We are pleased to inform you that we have tested your account's sendmail successfully as it is functioning as expected. We ask that you test your script again. Please note, the script will not function for 3 email addresses as this is not supported."

I find that a little disconcerting, especially cause for my website I really want to be able to send more than 2 emails.

Anyways, I appreciate the help. If I ever find away around this I'll post just in case someone else is having a similar problem.
The more you teach me, the more I learn. The more I learn, the more I teach.


KevinR
Veteran


Feb 23, 2007, 4:48 PM

Post #11 of 13 (1395 views)
Re: [PGScooter] sendmail problems with more than 2 recipients [In reply to] Can't Post

just loop through the email addresses and send one at a time.
-------------------------------------------------


PGScooter
stranger

Feb 23, 2007, 5:19 PM

Post #12 of 13 (1394 views)
Re: [KevinR] sendmail problems with more than 2 recipients [In reply to] Can't Post

Nope, still doesn't work. It goes through the loop and successfully opens up SENDMAIL, but I only receive the email at the first address..

Another interesting thing is that the script works really well for gmail addresses but I can't seem to get it to work for my hotmail address... I don't know if that's netfirms's problem or hotmail's.


Code
@myemails=('1234@gmail.com','4566@gmail.com','33444@hotmail.com'); 

foreach $toemail (@myemails) {
#my $comments = "Hi, I've decided to make a personal goal for myself and wanted to share it with you. Here are the details of my goal: $goal";
my $comments= "alright, I'm testing the loop Idea: @myemails";
open ( MAIL, "| /usr/lib/sendmail -t" );
print MAIL "From: $email\n";
print MAIL "To: $toemail\n";
print MAIL "Subject: Name's Goal!\n\n";
print MAIL "$comments\n";
close ( MAIL );
open(TESTING,">>testingloops.txt") or die "can't open testing file";
print TESTING "loop completed for $toemail";
close(TESTING);
}

The more you teach me, the more I learn. The more I learn, the more I teach.


KevinR
Veteran


Feb 23, 2007, 8:44 PM

Post #13 of 13 (1391 views)
Re: [PGScooter] sendmail problems with more than 2 recipients [In reply to] Can't Post

must be netfirms, like I said before, they are a bit of an odd bird.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives