Page 1 of 2
mailing list question :/
Posted: Mon Oct 21, 2002 3:50 pm
by qads
hi,
i am makeing a mailing list manager, let's say i have 50 email addresses in datbase to which i want to send a email.
useing the code below will take ages to send one email at a time
Code: Select all
$query = mysql_query("select name, email from table bla bla");
while(list($name, $email) = mysql_fetch_row($query))
{
bla bla bla bla
}
and if i load the all the email addresses into a array and send it then all users will see other users email addresses....
if this made sense to you then what do i do? what do i need to do to make sure that the emails are sent to all users, and the users don't see others email addresses.....
thanks alot for your time.
- Qads
Posted: Mon Oct 21, 2002 4:04 pm
by twigletmac
You can use the additional headers parameter of the
mail() function to send e-mails using BCC which hides all the email addresses. It may not work on all systems so you need to test locally to see if it will work for you.
Mac
Posted: Mon Oct 21, 2002 5:55 pm
by qads
i thought about that, but was't sure if it will work on all systems as you said..guess i have't got many options here
thanks
Posted: Mon Oct 21, 2002 7:29 pm
by sav
twigletmac wrote:You can use the additional headers parameter of the
mail() function to send e-mails using BCC which hides all the email addresses.
I recommend you to use for 'To:' field some 'dumb' address like '
no-mail@domain.tld'
Set up this address as
forward to
:blackhole: to prevent responses if you don't need one.
It may not work on all systems so you need to test locally to see if it will work for you.
Mac
It may not work if
mail() function disabled - just ask your host admin to enable it for you

Posted: Mon Oct 21, 2002 10:18 pm
by mr_griff
Would connecting directly to a SMTP server be any faster? Also would that give you the result of trying to send the mail (for example of it gets returned)?
Posted: Mon Oct 21, 2002 11:10 pm
by sav
mr_griff wrote:Would connecting directly to a SMTP server be any faster?
Faster? - I'm not sure. But it is the best way to send your emails. IMHO
Also would that give you the result of trying to send the mail (for example of it gets returned)?
Server just can say "Yes, your mail was accepted for delivery!"
But mail() and SMTP both cannot get you 'varanty of any kind'

If message gets returned due to some reason you have to set 'From' and/or 'Return-path' fieds to
real pop account on you server to get this messages back.
And you (yours script) have to check this account.
Sometimes ;D
Posted: Tue Oct 22, 2002 1:52 am
by twigletmac
sav wrote:twigletmac wrote:It may not work on all systems so you need to test locally to see if it will work for you.
It may not work if
mail() function disabled - just ask your host admin to enable it for you

Or if you're on a Windows server (yes, I know, another reason not to be...).
Mac
Posted: Tue Oct 22, 2002 1:59 am
by volka
uh? mail() works on win32.
Posted: Tue Oct 22, 2002 1:59 am
by twigletmac
But BCC doesn't.
Mac
Posted: Tue Oct 22, 2002 2:05 am
by volka
ah, right
hurry up 4.3.stable, go go go

Posted: Tue Oct 22, 2002 6:20 am
by qads
Code: Select all
$re = mysql_query("SELECT `ID`, name, `email` FROM `members`");
$sendmail = mysql_fetch_array($re);
$message = stripcslashes($message);
$email = $sendmailїemail];
$formset = mail($email,"$subject - News Letter","$message","From:$getїmail]");
here is the code, it only sends email to whatever address is first in array.
do i need to use each(); function, if so then how? i tried but it did't work($email = each($sendmail[email]);)
thanks for your help.
- Qads
Posted: Tue Oct 22, 2002 10:00 am
by DeGauss
for ($x=0;$x<=count($emailAddressArray);$x++) {
mail($emailAddressArray[$x])...
}
Who needs each when you've got the power of for and $x=0 ;D
Posted: Tue Oct 22, 2002 10:16 am
by qads
i havce't tested this so i am just gona say this:P
is't that like the while loop i am useing above? while loop send emails one by one..and so does this..if this works i am gona slap my self

.
Posted: Tue Oct 22, 2002 10:22 am
by DeGauss
if it works it works. I'm not the kind of person to give you an exact solution, i'm just going to poke you in the right direction.
Mind you, i just have a natural distrust of while, unless i'm using it in conjuction with mysql_fetch_array.
Also, if you want to check if each email got sent alright, you could do this:
if (mail(blah@blah,yada)) {
$message.="email to
blah@blah.com was sent successfully!\n";
} else {
$message.="email to
blah@blah.com was NOT sent successfully!\n";
}
...After the for/while loop...
mail(
you@yourdomain.com,$message);
for a message transaction digest. Or something.
Posted: Tue Oct 22, 2002 10:32 am
by qads
Code: Select all
for ($x=0;$x<=count($sendmailїemail]);$x++)
{
$formset = mail("$sendmailїemail]","$subject - News Letter","$message1","From:$getїmail]");
print("$sendmailїemail]<br>");
}
Print("<b>Email(s) Has Been Sent!</b>");
this still sends it to whichever address is at the top :/