/    Sign up×
Community /Pin to ProfileBookmark

Mass Mailing Script!

Hi all,

I have the following code…

[code=php]<?php

// specify includes
$fp = ‘../’;
require_once($fp . ‘functions/database.php’);
require_once($fp . ‘functions/mail.php’);

// ——————–

// read message
$filename = ‘june-test.php’;
$handle = fopen($filename, ‘r’);
$html = fread($handle, filesize($filename));
fclose($handle);

// query for customer data
$q = “SELECT * FROM customer WHERE email_opt = 1”; // returns around 2000 lines
$result = queryDatabase($q);
echo ‘<p>numRows: ‘ . mysql_num_rows($result) . ‘</p>’;
while ($row = mysql_fetch_array($result))
{
// format message
$message = str_replace(‘[first]’, $row[‘first_name’], $html);
$message = str_replace(‘[last]’, $row[‘last_name’], $message);
$message = str_replace(‘[email]’, $row[’email_address’], $message);

// send mail
$mailResult = sendMail($row[’email_address’], ‘15% off everything!’, $message, ‘Outlook Images <[email protected]>’);

// output result
echo ‘<p>’ . $mailResult . ‘ – ‘ . $row[’email_address’] . ‘</p>’;
}

?>[/code]

…however when I run it I get a 500 internal server error. Any ideas why?

Thanks,

dai.hop

to post a comment
PHP

1 Comments(s)

×

Success!

Help @dai_hop spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...