1

I am trying to make 2 forms. 1 simple contact form, 2 only for email.

I want to use magentos email system (contact email) so i am using if else in the email template.

My second form template wont send. I get the "could not send email"

most likely some little typo or something. can you help?

Here are the code

Contact form template (standard magento)

<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<div class="page-title" style="margin-left: 2%;">
    <h1><?php echo Mage::helper('contacts')->__('Kontakt IFP') ?></h1>
</div>
<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
    <div class="fieldset">
        <h2 class="legend"><?php echo Mage::helper('contacts')->__('Kontaktformular') ?></h2>
        <ul class="form-list">
            <li class="fields">
                <div class="field" style="padding-right: 1%;">
                    <label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label>
                    <div class="input-box">
                        <input name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
                    </div>
                </div> &nbsp;
                <div class="field">
                    <label for="email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label>
                    <div class="input-box">
                        <input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
                    </div>
                </div>
            </li>
            <li>
                <label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label>
                <div class="input-box">
                    <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" type="text" />
                </div>
            </li>
            <li class="wide">
                <label for="comment" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Comment') ?></label>
                <div class="input-box">
                    <textarea style="width: 100%;" name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
                </div>
            </li>
        </ul>
    </div>
    <div class="buttons-set">
        <p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
        <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
        <button type="submit" title="<?php echo Mage::helper('contacts')->__('Submit') ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
    </div>
</form>
<script type="text/javascript">
//<![CDATA[
    var contactForm = new VarienForm('contactForm', true);
//]]>
</script>

Second form template(custom)should only contain email field

<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
    <div class="fieldset">
        <ul class="form-list">
            <li class="fields">
                <div>
                    <input type="hidden" name="custom" value="1" />
                    <label for="email" class="required"><em>*</em><?php echo $this->__('Email') ?></label>
                    <div class="input-box">
                        <input name="email" id="email" title="<?php echo $this->__('Email') ?>"  class="input-text required-entry validate-email" type="text" />
                    </div>
                </div>
            </li>


        </ul>
    </div>
    <div class="buttons-set">
        <p class="required"><?php echo $this->__('* Required Fields') ?></p>
        <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
        <button type="submit" title="<?php echo $this->__('Afmeld') ?>" class="button"><span><span><?php echo $this->__('Afmeld') ?></span></span></button>
    </div>
</form>

Email template

{{if data.custom}}
    E-mail: {{var data.email}} :  Skal fjernes fra mail liste
{{else}}
    Navn: {{var data.name}}
E-mail: {{var data.email}}
Telefon: {{var data.telephone}}

Besked: {{var data.comment}}
{{/if}}
  • what is this function work onsubmit="return custom_submit()" – Qaisar Satti Apr 19 '16 at 12:46
  • it was just somehting i tried to get it to work, just ignore that – Patrick Knudsen Apr 19 '16 at 12:47
  • where are you set this data.custom variable? – Qaisar Satti Apr 19 '16 at 12:51
  • its a hidden input in second form. <input type="hidden" name="custom" value="1" /> – Patrick Knudsen Apr 19 '16 at 12:52
  • email sending code? – Qaisar Satti Apr 19 '16 at 12:55
0

add name and commen fields as hidden

<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
    <div class="fieldset">
        <ul class="form-list">
            <li class="fields">
                <div>
                    <input type="hidden" name="custom" value="1" />
                    <input type="hidden" name="name" value="test" />
                    <input type="hidden" name="comment" value="test" />
                    <label for="email" class="required"><em>*</em><?php echo $this->__('Email') ?></label>
                    <div class="input-box">
                        <input name="email" id="email" title="<?php echo $this->__('Email') ?>"  class="input-text required-entry validate-email" type="text" />
                    </div>
                </div>
            </li>


        </ul>
    </div>
    <div class="buttons-set">
        <p class="required"><?php echo $this->__('* Required Fields') ?></p>
        <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
        <button type="submit" title="<?php echo $this->__('Afmeld') ?>" class="button"><span><span><?php echo $this->__('Afmeld') ?></span></span></button>
    </div>
</form>
  • 1
    That way it will be validaded! ;) You are gold Qaisar! – Patrick Knudsen Apr 20 '16 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.