Page 1 of 1

Email Contacts List from mysql

Posted: Sat Nov 03, 2007 1:32 pm
by Apryle
I have a mysql database 'members' containing name, email, phone, etc for members.

I have a page that echos members names and email addresses. I want to be able to select multiple email addresses from this list (via ctrl click, via checkboxes, I don't really care... just want to be able to pick and choose who will receive the email).

After selecting the members I want to email, I click "Create Email to these Members" or the like and it takes me to the next screen to fill in the subject and body of the email via an online form.

I can successfully create an online html form that sends via php (see php I've been using below). I can successfully echo the members names and email addresses onto a page.

Code: Select all

<?php

$Name = Trim(stripslashes($_POST['Name'])); 
$Phone = Trim(stripslashes($_POST['Phone'])); 
$CellPhone = Trim(stripslashes($_POST['CellPhone']));
$Email = Trim(stripslashes($_POST['Email']));
$Fax = Trim(stripslashes($_POST['Fax']));
$RequestedInfo = Trim(stripslashes($_POST['RequestedInfo']));


// set email parameters
$to      = 'epboard@estesparkrealtors.org';
$subject = 'Info Request from REALTOR Website';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: EPBOR Website' . "\r\n";
$headers .= "Reply-To: $Email\r\n";


// prepare email body text
// email body text

$Body .= "Date: ".date("m/d/Y");
$Body .= "<br />";
$Body .= "Name: " .$Name . "<br />";
$Body .= "<br />";

$Body .= "Telephone: " . $Phone . "<br />";
$Body .= "Email: <a href='mailto:" . $Email ."'>" . $Email . "</a><br />";
$Body .= "<br />";

$Body .= "Requested Information: " . $RequestedInfo . "<br />";
$Body .= "<br />";


// send email 
$success = mail($to, $subject, $Body, $headers);

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.shtml\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=formerror.shtml\">";
}
?>
Any help is greatly apprciated.

Posted: Sat Nov 03, 2007 1:46 pm
by feyd
You may want to use Swift Mailer to simplify the creation of emails to all of these members.

Posted: Sat Nov 03, 2007 5:09 pm
by Apryle
Thanks. I will look into Swift Mailer. It looks more efficient than what I've been using.

Correct me if I'm wrong, but it won't provide the interface (it is not a contact list manager system), it will just drive the actually "sending" of the email(s).

Thanks.