I am having difficulty making my custom email form receive emails. My success message does not show when the submit button is clicked. I also am getting a Confirm Form Resubmission error when refreshing the page after clicking submit. I am not sure what I am missing to make it work.
Any help would be much appreciate. Here is my php controller function:
public function sendemailAction()
{
$email = $this->getRequest()->get('email');
$name = $this->getRequest()->get('name');
$comment = $this->getRequest()->get('comment');
$contact = $this->getRequest()->get('support_contact');
$session = $this->getSession();
$mail = new Zend_Mail();
$mail->setBodyText($comment);
$mail->setFrom($email, $name);
$mail->setSubject('Vendor Support');
$mail->addTo($contact . '@example.com');
try {
$mail->send();
$session->addSuccess($this->__('Thank You! We will get in touch with you as soon as possible.'));
} catch (Exception $ex) {
Mage::getSingleton('udropship/session')->addError('Unable to send email.');
}
$this->_redirect('udropship/vendor');
}
My layout.xml
file:
<udropship_vendor_support>
<update handle="udropship_vendor" />
<reference name="content">
<block name="vendor.support" type="itemique_dropship/template" template="unirgy/dropship/vendor/support.phtml"/>
</reference>
</udropship_vendor_support>
And my support phtml file:
<form id="support-form" class="standalone-form" action="<?php echo $this->getUrl('udropship/vendor/support'); ?>" method="post" enctype="application/x-www-form-urlencoded">
<h1><?php echo $helper->__('How can we help?'); ?></h1>
<fieldset class="form-content">
<div class="form-row">
<label for="support_contact">Contact department <span class="required">*</span></label>
<select id="support_contact" class="select" name="support_contact" required>
<option value="" disabled selected>--Please Select--</option>
<option value="billing">Billing Enquiries</option>
<option value="content">Content Support</option>
<option value="tech">Technical Support</option>
<option value="contact">Customer Service</option>
</select>
</div>
<div class="form-row">
<label for="comment">Your issue? <span class="required">*</span></label>
<textarea class="textarea" name="comment" id="comment" required></textarea>
</div>
</fieldset>
<div class="buttons-set">
<p class="required">* Required Fields</p>
<button type="submit" class="btn primary" name="send">
<span><?php echo $helper->__('Submit') ?></span>
</button>
</div>