Is it possible to send an e-mail programmatically in Magento? Maybe from a controller in a custom module, could you get hold of a template, populate its variables, and send
It's certainly possible. The email handling in Magento is quite powerful (and can be complex).
Without knowing exactly what you're trying to achieve, it would be worth you starting off by looking at the Mage_Core_Model_Email_Template class as that drives Magento's email handling.
Absolutely. Here's an example from the Checkout helper:
$mailTemplate = Mage::getModel('core/email_template');
$template = Mage::getStoreConfig('checkout/payment_failed/template', $checkout->getStoreId());
$mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>$checkout->getStoreId()))
->sendTransactional(
$template,
Mage::getStoreConfig('checkout/payment_failed/identity', $checkout->getStoreId()),
$recipient['email'],
$recipient['name'],
array(
'reason' => $message,
...
'total' => $total
)
);