..then sell it on ebay for a CPU/Video card
Extremely Simple Mailing List
Moderator: General Moderators
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
furiousweebee
- Forum Commoner
- Posts: 69
- Joined: Sun Jul 11, 2004 7:38 am
- Location: Brisbane, Australia
- Contact:
-
furiousweebee
- Forum Commoner
- Posts: 69
- Joined: Sun Jul 11, 2004 7:38 am
- Location: Brisbane, Australia
- Contact:
Ok, so here's what I have now:furiousweebee wrote:Okie dokie, thanks a lot for that. So now I could just use that code there (along with my original code) to send the email, and create a file (called massMailTemplate_html.dat) with normal HTML in it, plus tags such as {message}?
Code: Select all
<?php
include('db.php');
$form['mail'] = '
<form action="?act=mail" method="post">
<input type="hidden" name="send" value="yes">
<table>
<tr>
<td>Subject:</td>
<td><input type="text" name="subject" value="Mailing List" cols="70" size="65"></td>
</tr>
<tr>
<td valign="top">Email Message:</td>
<td><textarea name="message" rows="15" cols="50"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Send To The Mailing List"></td>
</tr>
</table>
</form>
';
$admin_forms = '';
switch (@$_GET['act']){
case 'mail':
if (!connect_db()){
$admin_forms = 'Error connecting to database, '.mysql_error().'.';
} else {
$res = mysql_query("SELECT email FROM mailing_list", $mysql_conn);
$filedata = file_get_contents('template.html');
if (@$_POST['send'] == 'yes'){
while ($row = mysql_fetch_assoc($res)){
$row['message'] = $_POST['message']; // add the handle for {message} tag
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "To: Fans <{$row['email']}>\r\n";
$headers .= "From: Mailing List <mailinglist@site.com>\r\n";
$headers .= "Reply-To: Mailing List <mailinglist@site.com>\r\n";
$headers .= "Return-Path: Mailing List <mailinglist@site.com>\r\n";
$admin_forms .= mail($row['email'], $_POST['subject'], stripslashes($_POST['message']), preg_replace('#\{([^\}]+?\}#e','repData("\\1",$row)',$filedata),$headers)?
'Email to '.$row['email'].' was successful.<br>':
'<strong>Email to '.$row['email'].' has failed.</strong><br>';
}
}
}
break;
case 'logout':
header("Location: ../index.php");
break;
default:
$admin_forms = $form['mail'].'<a href="?act=logout">Log Out</a>';
}
?>Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>mail template</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
Howdy,<br><br>
{message}<br><br>
Thanks!
<body>
</body>
</html>1. The template doesn't appear to be used, as only the message entered in my email form gets sent (no "Howdy" etc from the template); and
2. Regardless of what I set the From: address to, it sends the email from myhostingaccountusername@mydomain.com
Any ideas on those things?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
$admin_forms .= mail($rowї'email'], $_POSTї'subject'], stripslashes($_POSTї'message']), preg_replace('#\{(ї^\}]+?\}#e','repData("\\1",$row)',$filedata),$headers)?mail() wrote:bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])
-
furiousweebee
- Forum Commoner
- Posts: 69
- Joined: Sun Jul 11, 2004 7:38 am
- Location: Brisbane, Australia
- Contact:
-
furiousweebee
- Forum Commoner
- Posts: 69
- Joined: Sun Jul 11, 2004 7:38 am
- Location: Brisbane, Australia
- Contact:
Originally:
Now:
Code: Select all
$admin_forms .= mail($row['email'], $_POST['subject'], stripslashes($_POST['message']), preg_replace('#\{([^\}]+?\}#e','repData("\\1",$row)',$filedata),$headers)?Code: Select all
$admin_forms .= mail($row['email'], $_POST['subject'], $_POST['message'], preg_replace('#\{([^\}]+?\}#e','repData("\\1",$row)',$filedata),$headers)?- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
$admin_forms .= mail($row['email'], $_POST['subject'], preg_replace('#\{([^\}]+?\}#e','repData("\\1",$row)',$filedata),$headers);-
furiousweebee
- Forum Commoner
- Posts: 69
- Joined: Sun Jul 11, 2004 7:38 am
- Location: Brisbane, Australia
- Contact:
-
furiousweebee
- Forum Commoner
- Posts: 69
- Joined: Sun Jul 11, 2004 7:38 am
- Location: Brisbane, Australia
- Contact:
-
furiousweebee
- Forum Commoner
- Posts: 69
- Joined: Sun Jul 11, 2004 7:38 am
- Location: Brisbane, Australia
- Contact:
-
furiousweebee
- Forum Commoner
- Posts: 69
- Joined: Sun Jul 11, 2004 7:38 am
- Location: Brisbane, Australia
- Contact:
I'm not sure how to echo that. 
I had already commented out the To: part but it was still sending duplicates. Here's what I have now:
I had already commented out the To: part but it was still sending duplicates. Here's what I have now:
Code: Select all
<?PHP
$res = mysql_query("SELECT email FROM mailing_list", $mysql_conn);
$filedata = file_get_contents('template.html');
if (@$_POST['send'] == 'yes'){
while ($row = mysql_fetch_assoc($res)){
$row['message'] = $_POST['message']; // add the handle for {message} tag
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Ten Foot Pole Mailing List <band@tenfootpole.com>\r\n";
$headers .= "Return-Path: Ten Foot Pole Mailing List <band@tenfootpole.com>\r\n";
$admin_forms .= mail($row['email'], $_POST['subject'], preg_replace('#\{([^\}]+?\}#e','repData("\\1",$row)',$filedata),$headers)?
'Email to '.$row['email'].' was successful.<br>':
'<strong>Email to '.$row['email'].' has failed.</strong><br>';
}
}
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
example
Code: Select all
$msg = preg_replace(.......);
mail($row['email'],$_POST['subject'],$msg,$headers)? // blah blah blah