Ask a Question related to PHP Development, Design and Development.
-
Joe #1
Need help formatting query for mail()
I want to use mail() to send a message to a group of addresses in a mysql
table. Išve got my mail script and my sql query, but I donšt know how to
format the query results to fit into the mail() function.
Does anyone have a simple script that will format a list of email addresses
(from a mysql query) then dump them into a variable that I can use in a
mail() function?
Herešs what I got so far:
mysql_select_db($database_mailinglist, $mailinglist);
$query_email = "SELECT * FROM emailaddress";
$email = mysql_query($query_email, $mailinglist) or die(mysql_error());
$row_email = mysql_fetch_assoc($email);
$totalRows_email = mysql_num_rows($email);
mail($addresses, "Successful Test", "Successful mail sent")
FYI ... Išm a novice programmer at best ...
Joe Guest
-
Need help formatting syntax for SELECT query on a Bittype data field
:confused; I have been trying to build a SQL statement in my coldfusion page that queries our SQL Server database for a bunch of records. I want to... -
CDO mail formatting issue
Hi, When I set the following for my CDO email, the mail is receievd with the html portion does not appear formatted but just as it is seen below. I... -
Mail formatting problem
I'm using this code below. It sends the emails ok but none ofthe body isformatted. Any ideas? Thanks Andy <% Dim BodyString -
<cfoutput query> and TABLE formatting
HI, I'm trying to output images from a database using <cfoutput query>. That part works fine. But the images display all in one column, one... -
E-mail formatting?
When e-mailing invoices and estimates, is there any way to customize the presentation of the e-mail beyond changing the message? Specifically, I'd... -
Sugapablo #2
Re: Need help formatting query for mail()
Joe wrote:
while($row_email = mysql_fetch_assoc($email)) {> mysql_select_db($database_mailinglist, $mailinglist);
> $query_email = "SELECT * FROM emailaddress";
> $email = mysql_query($query_email, $mailinglist) or die(mysql_error());
> $totalRows_email = mysql_num_rows($email);
$to = $row_email['addresses']; // where addresses is your column name
$subject = "Your subject";
$message = "Your message";
$headers = "From: [email]you@email.com[/email]\r\n";
mail($to, $subject, $message, $headers);
}
--
Sugapablo
------------------------------------
[url]http://www.sugapablo.com[/url] <--music
[url]http://www.sugapablo.net[/url] <--personal
Sugapablo Guest
-
Joe #3
Re: Need help formatting query for mail()
Thank you Sugapablo!!!
in article [email]vmn3j1i9dkbkfe@corp.supernews.com[/email], Sugapablo at
[email]russREMOVE@sugapablo.com[/email] wrote on 9/19/03 6:12 PM:
> Joe wrote:>>> mysql_select_db($database_mailinglist, $mailinglist);
>> $query_email = "SELECT * FROM emailaddress";
>> $email = mysql_query($query_email, $mailinglist) or die(mysql_error());
>> $totalRows_email = mysql_num_rows($email);
> while($row_email = mysql_fetch_assoc($email)) {
> $to = $row_email['addresses']; // where addresses is your column name
> $subject = "Your subject";
> $message = "Your message";
> $headers = "From: [email]you@email.com[/email]\r\n";
>
> mail($to, $subject, $message, $headers);
> }
>Joe Guest
-
Richard Hockey #4
Re: Need help formatting query for mail()
"Sugapablo" <russREMOVE@sugapablo.com> wrote in message
news:vmn3j1i9dkbkfe@corp.supernews.com...You can send to multiple recipients with one call to the function mail(), if> Joe wrote:>> > mysql_select_db($database_mailinglist, $mailinglist);
> > $query_email = "SELECT * FROM emailaddress";
> > $email = mysql_query($query_email, $mailinglist) or die(mysql_error());
> > $totalRows_email = mysql_num_rows($email);
you place the e-mail addresses in a comma seperatd list
$to="";
// loop through database query to fetch recipient e-mail addresses
// output comma seperated list of e-mail addresses in $to
while($row_email = mysql_fetch_assoc($email))
{
if($to!="") $tp.=", ";
$to.= $row_email['addresses']; // where addresses is your column name
}
// assuming the message subject and content are the same for all the
messages
$subject = "Your subject";
$message = "Your message";
$headers = "From: [email]you@email.com[/email]\r\n";
mail($to, $subject, $message, $headers);
There is one disadvantage to this, in that the message header the recipients
see will contain a list of all the e-mail addresses the message was sent to.
Richard Hockey Guest
-
Geoff Berrow #5
Re: Need help formatting query for mail()
I noticed that Message-ID: <3f6d6933$0$254$cc9e4d1f@news.dial.pipex.com>
from Richard Hockey contained the following:
You can use bcc:>$subject = "Your subject";
>$message = "Your message";
>$headers = "From: [email]you@email.com[/email]\r\n";
> mail($to, $subject, $message, $headers);
>
>There is one disadvantage to this, in that the message header the recipients
>see will contain a list of all the e-mail addresses the message was sent to.
$recipient = "My customers";
$subject = "Your subject";
$message = "Your message";
$headers = "bcc: $to\nFrom: [email]you@email.com[/email]\r\n";
mail($to, $subject, $message, $headers);
--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs [url]http://www.ckdog.co.uk/rfdmaker/[/url]
Geoff Berrow Guest
-
Martin Lucas-Smith #6
Re: Need help formatting query for mail()
A useful technique is to change this to> mail($to, $subject, $message, $headers);
mail($to, $subject, wordwrap ($message), $headers);
so that the message line length is kept to <80 characters, for
compatibility with most/all mail clients.
Martin Lucas-Smith [url]www.geog.cam.ac.uk/~mvl22[/url]
[url]www.lucas-smith.co.uk[/url]
Martin Lucas-Smith Guest



Reply With Quote

