Author Topic: Code to send Email using FCKEditor  (Read 5790 times)

Offline mdemaree99

  • Posts: 102
Code to send Email using FCKEditor
« on: January 04, 2012, 08:15:36 PM »
Code to send out html email using front end with FCKEditor

Contains some ugly code since I am pulling email addreses from access database, but tried to put comments in so you could use a mysql db.

Issues for now.
1)  When I post internal link from website it shows up at a droplet.
      Internal links look like this:     http://[wblink29]

      Solution:  Send all links as external link.
      Internal links will show up normal.

I didn't think about security of form since user must be registered and an admin to use the page.
Any security or ideas let me now and i'll incorportate it.

Downside is that this does not save a list of emails that have previously been sent.
However easier to manipulate than the other mass email programs.

Code: [Select]
$bccquery ="";
//initialize the to field for email
$toinitial ="";

//connect to database (this used for MS Access Database
$conn = new COM('ADODB.Connection') or die('Could not make conn');
$rs = new COM('ADODB.Recordset') or die('Coult not make rs');
$connstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=mydb.mdb";

//Connect to WebsiteBaker db
//My best guess at websitbaker query
//$query = "SELECT email FROM ".TABLE_PREFIX."users WHERE group_id <> 0";
//$result = $database->query($query);

// Select your email addresses in a search
$sql = "SELECT [E-MAIL], ClassCode FROM tblMembership
       Where ClassCode IN (1, 2, 3,4,5)
       AND [E-Mail] <> ''

//More access db
$rs->Open($sql, $conn, 1, 3);

while(!$rs->EOF) {

//$bccquery = $bccquery .$rs->Fields['E-Mail']->Value . "," ;


//Close access database



// now lets send the email.
//retrieves data from form
$to = $_POST['toemail'];
//Retrieves Subject of Email from Form
$subject = $_POST['subject'];
//$email = $_POST['email'] ;
//change this to your email.
    $to = $_POST['toemail'];
    $from = '' ;

//begin of HTML message
$message = $_POST['message'] ;
$message = stripslashes($message);

 //change this to JLA email.
    $to = $_POST['toemail'] ;
//Sets who email is from  
    $from = "";
//Header field for email  (need from to detrmine header)
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";
//options to send to cc
   $ccemail = $_POST['ccemail'] ;
    if ($ccemail<>'')
   { $headers .= "Cc: $ccemail\r\n"; }
//options to send bcc
   $bccemail = $_POST['bccemail'] ;
   if ($bccemail<>'')
   {$headers .= "Bcc: $bccemail\r\n"; }

if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form

// FORM to input data for email
//Predefines fields for the form
 $toemail = '';
 $ccemail = '';
 $bccemail = $bccquery;

echo (" <form method='post' action=$PHP_SELF>  ");
echo ("<table>");

echo (" <tr><td valign='top'>TO:</td>");
echo (" <td><textarea name='toemail' type='text' rows='1' cols='50'>$toemail</textarea></td></tr>");

echo (" <tr><td valign='top'>CC:</td>");
echo ("<td> <textarea name='ccemail' type='text' rows='1' cols='50'>$ccemail</textarea></td></tr>");

echo (" <tr><td valign='top'>   BCC:     </td> ");
echo ("<td> <textarea name='bccemail' type='text' rows='4' cols='50' />$bccemail</textarea></td></tr>");

echo (" <tr><td valign='top'>   SUBJECT: </td> ");
echo (" <td> <textarea name='subject' type='text' rows='1' cols='50' /></textarea></td></tr>  ");

ECHO (" <TR><td>Body:</td><TD> ");
ECHO ('  <input type="hidden" name="bd937a97e1a1514d" value="e1a1514d74ca5783" title="" alt="" />  ');

//Must modify to your website --see note below
ECHO ('  <input type="hidden" id="message" name="message" value="" style="display:none"/><input type="hidden" id="message___Config" value="CustomConfigurationsPath=;EditorAreaCSS=;StylesXmlPath=;TemplatesXmlPath=;LinkBrowserURL=;ImageBrowserURL=;FlashBrowserURL=" style="display:none" /><iframe id="message___Frame" src=";Toolbar=WBToolbar" width="100%" height="350" frameborder="0" scrolling="no"></iframe>  ');
ECHO ("  </TD></TR> ");

//Must modify to your website
// Create a page in WebsiteBaker with WYSIWYG section
// right click to view source and copy FCKEditor settings.
// replace all content64 with item you are pulling from post  (previous is message)
//ECHO ('  <input type="hidden" name="bd937a97e1a1514d" value="e1a1514d74ca5783" title="" alt="" />  ');
//ECHO ('  <input type="hidden" id="content64" name="content64" value="" style="display:none" /><input type="hidden" id="content64___Config" value="CustomConfigurationsPath=;EditorAreaCSS=;StylesXmlPath=;TemplatesXmlPath=;LinkBrowserURL=;ImageBrowserURL=;FlashBrowserURL=" style="display:none" /><iframe id="content64___Frame" src=";Toolbar=WBToolbar" width="100%" height="350" frameborder="0" scrolling="no"></iframe>  ');

echo (" <tr><td colspan='2' style='text-align: center;'> <input type='submit' value='Send Email' name='submit'></td></tr> ");
echo ("  </table>  ");  
echo (" </form>");

//Send email once email is complete and Send Email clicked

} else {
    // now lets send the email.
          if (mail($to, $subject, $message, $headers))
                  //this will give user a view on what email will look like        
                      echo "Message has been sent....!";    
                      echo "Message has been sent....!<br><br>";  
                      echo ("From: $from <br> ");
                      echo ("TO: $to <br> ");
                      echo ("CC:  $ccemail <br>");
                      echo ("BCC: $bccemail <br>");
                      echo ("Subject: $subject <br><BR>");
                      echo ("Body: <br> $message ");
             else {            
                    echo 'There was a problem sending the email.';          

« Last Edit: January 04, 2012, 08:21:49 PM by mdemaree99 »