I have added a simple subscription form to my Magento site. The form is displaying nicely and the post redirects to my controller without a problem. My issue is actually sending an email. Now I must point out that I'm a bit of a noob with Magento.
My code so far.
$mail = Mage::getModel('core/email');
$mail->setToName('Your Name');
$mail->setToEmail('me@gmail.com');
$mail->setBody('Mail Text / Mail Content');
$mail->setSubject('Mail Subject');
$mail->setFromEmail('me@gmail.com');
$mail->setFromName("Msg to Show on Subject");
$mail->setType('html');
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
$this->_redirect('');
}
catch (Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send.');
$this->_redirect('');
}
I have been digging through sites and I have pieced this together from what I have found.
Each time the method runs I just get "unable to send"
Is there a good way to debug the mail->send() method as at the moment I have no idea what is failing, just that it is failing.
Thanks in advance