I'm building a system that will eventually send lots of emails, so I've split the transmission stuff in to two parts; the first part stores the email (so that it doesn't have to be regularly rebuilt) and a list of the people to whom it should be sent, and then the second part is a function that'll get called from cron regularly, which goes through and retrieves the email and pulls out batches of people and sends it to them.
however, I'm having trouble storing and retrieving the actual "compiled" email to a mysql database.
in the first function, I:
Create the new message:
Code: Select all
$message =& new Swift_Message($emailtitle);and then to get the $message object in to the database, i've tried serializing/unserializing whilst adding/stripping slashes, I've also tried base64 encoding/decoding the serialised object. the second function has thus far always failed to properly load it (more on that later)
I've noticed (with phpmyadmin) that the field that this gets stored to in the database never ends up with any slashes in it, even when i use addslashes to make it safe to go in to the database...
Then, in the second function which loops and actually transmits the emails, I initialise swiftmailer:
Code: Select all
Swift_Errors::expect($e, "Swift_Exception");Code: Select all
if ($swift->send($message, new Swift_Address($email,"$firstname $lastname"), new Swift_Address($this->smtp_from,$this->smtp_from_name)))I've tried all different sorts of combinations of adding and stripping slashes, serializing/unserializing, base64 enc/dec etc; different orders (ie serializing before adding slashes; or adding slashes before serializing) and nothing works
I either get
Code: Select all
Notice: Swift::send expects parameter 1 to be instance of Swift_Message. in C:\Program Files\AppServ\www\snip\inc\swiftmailer\lib\Swift.php on line 381or I get
Code: Select all
Fatal error: Unknown(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition swift_message_headers of the object you are trying to operate on was loaded _before_ the session was started in C:\Program Files\AppServ\www\snip\inc\swiftmailer\lib\Swift\Message\Mime.php on line 242(on that point; can anyone please tell me why when get this particular error message and then var_dump the retreived $message, it actually seems to output the email about 28 times? the stored version of it in the database doesn't have it stored like that, and there's no loop causing it to come out 28 times)
i've stored arrays to a database with serialize() before; what am I missing here?
thankyou so much!!