SWIFT MAILER please help

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
mgkmn
Forum Newbie
Posts: 1
Joined: Mon Aug 13, 2007 12:39 am

SWIFT MAILER please help

Post by mgkmn »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hey guys, i want to make a newsletter that will mail automatically to people on my sql db. I have the following code and it generates an error. (I passed all the smoketests)

Code: Select all

<?php $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); }// 

mysql_select_db("db", $con); 

//Load in the files we'll need 
require_once "lib/Swift.php"; 
require_once "lib/Swift/Connection/Sendmail.php"; 
require_once "lib/Swift/Plugin/Decorator.php"; 
$swift =& new Swift(new Swift_Connection_Sendmail()); 
  $name = $recipient['name']; 
$exmail = $recipient['exmail']; 

// this allows template variables to be evaluated 
      $formatted = addslashes(html_entity_decode($template['formatted'])); 
      eval("\$formatted = "$formatted";"); 
   
      // evaluate textmessage 
      $textmessage = addslashes(html_entity_decode($template['textmessage'])); 
      eval("\$textmessage = "$textmessage";"); 
   
      // build HTML message body 
      $htmlbody = & new Swift_Message_Part(stripslashes($formatted), "text/html"); 
      // build plain text message body 
      $plaintextbody = & new Swift_Message_Part(stripslashes($textmessage), 'text/plain'); 
       
      // attach the parts to the message 
      $message->attach($plaintextbody); 
      $message->attach($htmlbody); 


$htmlbody =& new Swift_Message("<u>Hey {name}, what's up?</u>", "Your E-mail is {exmail}?"); 

        $query = "select 
        name as `{name}`, email as `{exmail}` 
        from clients" 

while($row = mysql_fetch_object($query))            
{ 
$recipients =& new Swift_RecipientList(); 
$recipients->addTo("$exmail"); 
$swift->batchSend($message, $recipients, "xexe@gmail.com"); 

} 
}
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

.... and the error is....
Post Reply