So I finally got around to moving my sandbox type stuff and my blog off of slicehost and onto linode. I rarely touch my blog and do anything with wordpress so it is always a bit of a chore to upgrade etc. ’cause I’m treading on unfamiliar ground.

Anyway, I thought I would give myself a challenge and run wordpress behind nginx. The formula is to proxy nginx to php-cgi. This worked fine but was horribly unstable as the php-cgi process goes down quite often. The problem was running spawn-fcgi from init.d. It needed to be run from a proper process manager. As luck would have it, I had supervisord already running to monitor uwsgi.

I wish I would have stumbled across this post from Grig Gheorghiu, as it would have saved me a lot of effort. Funny how he is also a python guy.

Magento seemingly makes the most mundane development tasks an exercise in patience. The over engineered PHP beast makes you do more XML situps than the most anal of Java app environments all with zero documentation of its convoluted naming conventions. Therefore, when I wanted to email from within a custom Magento module I found myself back in the Magento source and forums to try and figure it out. I was just about to go down Asad Rahman’s approach or Branko Ajzele’s but digging around in Magento’s source led me to believe there was an easier way. Please note, however, if you want to take a template approach to emailing then you are probably left with the aforementioned approaches and I wish you luck. This approach is very straight forward and about as simple as it gets in Magento. The following function probably doesn’t need a lot of explanation:

public function notify($sendToName, $sendToEmail, $subject, $msg) {
 
    Mage::log("Sending email to $sendTo");
 
    $mail = Mage::getModel('core/email');
    $mail->setToName($sendToName);
    $mail->setToEmail($sendToEmail);
    $mail->setBody($msg);
    $mail->setSubject('=?utf-8?B?'.base64_encode($subject).'?=');
    $mail->setFromEmail("support@example.com");
    $mail->setFromName("Your Friendly Neighbourhood Support");
    $mail->setType('text');
 
    try {
        $mail->send();
    }
    catch (Exception $e) {
        Mage::logException($e);
        return false;
    }
 
    return true;
}
© 2012 rootsmith blog Suffusion theme by Sayontan Sinha