Email Contacts List from mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Apryle
Forum Newbie
Posts: 7
Joined: Wed Jul 18, 2007 12:54 pm

Email Contacts List from mysql

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You may want to use Swift Mailer to simplify the creation of emails to all of these members.
Apryle
Forum Newbie
Posts: 7
Joined: Wed Jul 18, 2007 12:54 pm

Post 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.
Post Reply