grafis Posted October 13, 2012 Share Posted October 13, 2012 Any tips or clues on how to send an email after a form is submitted? I'm looking to send a Welcome! email to anyone who registers. Seems like it should be fairly easy but I'm not smart... enough to decipher the Smarty code yet :-) Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted October 13, 2012 Share Posted October 13, 2012 I hired a developer to add another status with the accompanying emails for me, and he did a great job. PM me if you'd like more info. Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 13, 2012 Share Posted October 13, 2012 The clue would be that the PHP code file that processes the data that the form submitted would then call the Mailer class, use various methods to setup the parts of an email, then use the send() method to get the email out the door. That's just the clue. I'll have a better explanation later. Quote Link to comment Share on other sites More sharing options...
grafis Posted October 20, 2012 Author Share Posted October 20, 2012 Hi bsmither, thanks for the clues. I'm on the cusp but can't quite figure it out. The forms are processed by the calling page on which I cannot find any reference to any other processes or classes (Mailer). I PM'ed you - any help appreciated! Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 20, 2012 Share Posted October 20, 2012 I'm working on adding the ability to have admin create more types of emails ("Welcome, thanks for registering", etc.). But let's start by looking at /classes/order.class.php, at around line 282. $admin_mailer = Mailer::getInstance(); This gives us a thing that we will use to do the mailing. The Mailer thing (an object) has properties (characteristics) and functions (actually called methods, that do actions). if (($content = $admin_mailer->loadContent('admin.order_received')) !== false) { The Mailer object knows how to fetch email content from the database. That content is actually a template used by Smarty and Smarty populates the {$placeholders} with data assembled in code from form submissions or other database calls. In the case we are looking at, that happened in lines 213-280. For this case, the email content being used is the message Order Received and is intended for the admins. Because this is a Smarty template, we use the Smarty object's assign() method to populate the template. Then we use the Mailer's method sendMail(who, what) to send the email on its way. To summarize: Assign to a variable a Mailer object. Determine what email content (which is a template) to send and give it to loadContent(). Use Smarty to populate the email content. Use sendmail() to send it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.