User Profile

User
 mhuggins
Location
 Pflugerville, TX
Time Zone
 
URL
 http://blackbooksingles.com

Recent Articles

Improved SwiftMailer Component

I've used the [url=http://bakery.cakephp.org/articles/view/sending-email-with-phpmailer]PHPMailer component[/url] previously, and it's useful for basic SMTP usage. However, I recently needed to make an SMTP connection requiring TLS authentication, which PHPMailer does not provide. To resolve this, I decided to switch to SwiftMailer. Unfortunately, I wasn't very satisfied with the ease of use of the existing [url=http://bakery.cakephp.org/articles/view/swiftmailer-component]SwiftMailer component[/url] I found on the Bakery. As such, I created my own component that is more similar to the original PHPMailer component I was using. It doesn't have attachments implemented, but it's handy for sending HTML/plaintext emails.
  • Published by mhuggins 06/11/08 - 13:41
  • 12090 views
  • 9 comments

Recent Comments

Posted 30/09/2009 02:07pm
Damn, I forgot I ever published this. I've made many changes and have learned much about CakePHP since the time I put this article up. I hope it helped some people, and I'm sorry about any missing explanations or pieces of code you needed. I may post my updated component in the future. :)
Posted 11/08/2009 05:37pm
Cool, I'm definitely going to have to check this out. One immediate thought from glancing over it though, why not just name the controller "PaypalIpnController" (paypal_ipn_controller.php)? That way you can avoid all the nasty custom routes.
Posted 14/06/2009 11:18pm
Huge thanks to your help with this, Wilson! I ended up creating a custom ForumUser model that works like a typical cake model (with the save() method overloaded, plus added login() and logout() methods). I have a little more work I'd like to do on it (e.g. I haven't implemented updating a user's data yet), but I'll share it here when I'm done.
Posted 12/04/2009 10:27pm
Awesome component idea! This is going to come in handy. With that said, I have two suggestions for improvement.

1. Internationalization Improvement


Utilize sprintf in conjunction with %s/%d/etc. placeholders in your string. This way you only have to convert one string in LC_MESSAGES instead of multiple similar strings.

For example, I changed this:

trigger_error(__('Process Callback not found. Please create Controller::' . $processCallback, true), E_USER_WARNING);
...to this:

trigger_error(sprintf(__('Process Callback not found. Please create Controller::%s', true), $processCallback), E_USER_WARNING);
Similarly, I changed this:

trigger_error(__('Step validation: ' . $step . ' is not a valid step.', true), E_USER_WARNING);
...to this:

trigger_error(sprintf(__('Step validation: %s is not a valid step.', true), $step), E_USER_WARNING);

2. View Rendering Improvement


Several of my prepare steps simply reuse existing views via Controller::render(). Typically, this prevents a view from autoRendering in CakePHP. I would recommend the WizardComponent do the same by not autoRendering if a view has already been rendered.

I did this by changing this line of the Component:

return $this->controller->render($this->_currentStep);
...to this:

return $this->controller->autoRender ? $this->controller->render($this->_currentStep) : true;
Posted 14/06/2008 03:43pm
Is caching only per element? For example, if I have a user dashboard, 2 users in the system will have different queries to get their own user data to be loaded into their dashboards. However, they will still be using the same view/elements. Will I not be able to cache this since then the second user would see the data cached by the first user?