PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Aug 04, 2020 4:00 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Jul 09, 2009 4:00 pm 
Offline
Forum Newbie

Joined: Thu Jul 09, 2009 3:43 pm
Posts: 3
Hi!

Today I started using swiftmailer with symfony and it looks very sexy; it's a Greate lib. But I have the following problem:

I am developing a webapp in symfony. And now I want to add a tell a friend form. My idea was to generate the email when the form is submitted and to safe it in the db.

In a cronjob I want to take the entry from the db and send it. Firstly I thought I can serialize the message object to put it in the db.
In the cronjob I wanted to unserialize the object, but this doesn't work.

Secondly I had the idea to store the mail source code retrieved from Swift_Message::toString() in the db. But now I see no way to send this source code. I see no way to give the finished mail source code to the Swift_Mailer object or to the Swift_Message object.

I want to store the finished email in the db because there are several places in my app which generate different mails. So I don't want to store the email fields(from, to, subject, ...) in the db.

Thankful for every hint,

misch


Top
 Profile  
 
PostPosted: Thu Jul 09, 2009 7:53 pm 
Offline
DevNet Resident
User avatar

Joined: Sun Feb 15, 2009 8:22 pm
Posts: 2119
Location: Ipswich, UK
What?

Why don't you just send the email when they submit it?


Top
 Profile  
 
PostPosted: Fri Jul 10, 2009 1:50 am 
Offline
Forum Newbie

Joined: Thu Jul 09, 2009 3:43 pm
Posts: 3
1. it' slowing down the response time of the form.
2. What about error management.
3. It's bad softeare design to mix several tasks in one. The job of the form is to take the submitted values, check them and generate the response.
4. What happends if I want the emails to be processed when the server is less in use by site visitors(at night).
5. If you have five places where you generate emails. I am sure you don't want to have five places where mails are sent.

misch


Top
 Profile  
 
PostPosted: Fri Jul 10, 2009 6:49 am 
Offline
DevNet Resident
User avatar

Joined: Sun Feb 15, 2009 8:22 pm
Posts: 2119
Location: Ipswich, UK
I honestly doubt a few hundred people using a mailing script would slow down your server at all...unless you've got a site with millions using at the same time or something.

But I'm not entirely sure of your problem....you can't retrieve them from the database?


Top
 Profile  
 
PostPosted: Fri Jul 10, 2009 6:58 am 
Offline
Forum Newbie

Joined: Thu Jul 09, 2009 3:43 pm
Posts: 3
Hi!

On my local server the process of sending the mail directly in the form takes two seconds.

I found a solution:

In the script processing the form I build the message object. Here I can also embed images and so on.
To the model of the db entry which has a blob column to store the message, I mad a function putMessage().
In this function I take all parameters from the message object via getTo(), getFrom(), ... and put it in a hash.
This hash gets serialized and saved in the blob.

In my sending batch file I use the retrieveMessage function of this model to get back swift_message. In this function I unserialize the hash and put all values back in a message object. setTo(), ...

It's not the finest solution but it works.

misch


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group