ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

email from form ignores variables 'name' and 'from'

October 21, 2008 5:32am

Subscribe [1]
  • #1 / Oct 21, 2008 5:32am

    hartmutd

    5 posts

    Maybe the problem is known and already solved, but I could not find any hint on it.
    I am using the e-mail contact form to allow visitors to send an email directly from our site. But instead of the variables ‘name’ and ‘from’ of the form fields, the e-mail-address and name of the e-mail configuration tab of the system preferences is used and displayed as addresser in the outgoing e-mail. The variables ‘subject’ and ‘message’ of the form are correctly implemented and transfered. Leaving the fields of the e-mail configuration tab blank, the e-mail of the form will not be send. Sending an e-mail by the communicate tab works fine with any e-mail address and name. How can I tell EE to use the variables of the form for the outgoing mail.
    Here my code:

    {exp:email:contact_form user_recipients="false" recipients="[email protected]" return="|Return to the Site" replyto="y"}
      <h2>Kontaktformular</h2>
    
    <p>  <label for="to" >An:  </label></p>
    
    <p>  <input type="text" id="to" name="to" size="35" maxlength="35" value="myname" readonly="readonly"  /><br ><br />
      <label for="name" >Ihr Name: *</label></p>
    
    <p>  <input type="text" id="name" name="name" size="35" maxlength="35" value="{member_name}" /><br ><br />
      <label for="from" >Ihre E-Mail: *</label></p>
    
    <p>  <input type="text" id="from" name="from" size="35" maxlength="35" value="{member_email}" /><br ><br />
      <label for="subject">Worum geht es?  </label></p>
    
    <p>  <input type="text" id="subject" name="subject" size="35" /><br ><br />
      <label for="message">Ihre Nachricht:  </label></p>
    
    <p>  <textarea id="message" name="message" rows="5" cols="28"></textarea></p>
    
    <p>  </p>
    
    <p>  {if captcha}<br />
      <label for="captcha">Bitte tragen Sie das angezeigte Wort ein:</label></p>
    
    <p>  {captcha} </p>
    
    <p>  <input type="text" id="captcha" name="captcha" value="" maxlength="20" /></p><br />
      {/if}<br />
      </p>
    
    <p>  <input name="submit" type="submit" class="right" title="Absenden - Bitte nur einmal klicken" value="Absenden" /></p><br />
    {/exp:email:contact_form}

  • #2 / Oct 21, 2008 10:28am

    Robin Sowell

    13255 posts

    Try removing the reply_to parameter.  That do the trick?  See docs for more detail:

    By default the email address sending the email will be put in the From header for the email. If this parameter is set to “y”, then that email address will be put into the Reply-To field and the site’s webmaster email will be put in the From header. This is necessary at times because certain email servers will not send an email with an address not from its domain, so ExpressionEngine will use the site’s webmaster email address to get past this restriction while still allowing any replies to go to the sender of the email.

  • #3 / Oct 21, 2008 11:43am

    hartmutd

    5 posts

    Thanks, but it seems that there is something strange going on in the system. I checked again the form without changing anything I got the error ‘Your email had no valid recipients.’. I deleted the ‘replyto’ variable but its still the same with the error. If I am login as admin via the control panel an try the e-mail form again I get the following error messages:

    Warning: mcrypt_get_iv_size(): Module initialization failed in /mnt/web7/10/11/5501211/htdocs/ssp-ee/modules/email/mod.email.php on line 206

    Warning: mcrypt_create_iv() [function.mcrypt-create-iv]: Can not create an IV with a size of less then 1 or greater then 2147483647 in /mnt/web7/10/11/5501211/htdocs/ssp-ee/modules/email/mod.email.php on line 207

    Warning: mcrypt_encrypt(): Module initialization failed in /mnt/web7/10/11/5501211/htdocs/ssp-ee/modules/email/mod.email.php on line 209

    Warning: mcrypt_get_iv_size(): Module initialization failed in /mnt/web7/10/11/5501211/htdocs/ssp-ee/modules/email/mod.email.php on line 576

    Warning: mcrypt_create_iv() [function.mcrypt-create-iv]: Can not create an IV with a size of less then 1 or greater then 2147483647 in /mnt/web7/10/11/5501211/htdocs/ssp-ee/modules/email/mod.email.php on line 577

    Warning: mcrypt_decrypt(): Module initialization failed in /mnt/web7/10/11/5501211/htdocs/ssp-ee/modules/email/mod.email.php on line 579

    The following errors were encountered
    Your email had no valid recipients.
    Return to Previous Page

    Whats to do?

  • #4 / Oct 21, 2008 11:53am

    Robin Sowell

    13255 posts

    I suspect there may be an issue with the libmycrypt library- server issue rather than EE specific.  See this thread for a similar issue.  EE checks that it’s installed before using it, but if it’s having issues, you could see this problem.

    For a quick test to see if that’s what’s up, you could try editing system/modules/email/mod.email.php- aruond line 203:

    if ( function_exists('mcrypt_encrypt') )
            {
                $init_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
                $init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
                
                $recipients = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($PREFS->ini('system_folder')), $recipients, MCRYPT_MODE_ECB, $init_vect);
            }

    Put a ! before function_exists- so it looks like:

    if ( ! function_exists('mcrypt_encrypt') )

    This isn’t a fix- but it will tell us whether the mcrypt function is the source of the problem.

    Make sense?

  • #5 / Oct 21, 2008 5:55pm

    hartmutd

    5 posts

    😏 Thanks Robin, that’s it, I canceled out the function (‘mcrypt_encrypt’) in line 203 and 514 in mod.email.php and the e-mail form is working pretty well as expected (with correct name and from variables). But it seems, I canceled out also the CAPTCHA function. However, for the first time the problem is solved. Should I reinstall the e-mail module?

  • #6 / Oct 22, 2008 10:19am

    Robin Sowell

    13255 posts

    In truth- at this point, I’d talk to your host.  Show them this code:

    if ( function_exists('mcrypt_encrypt') )
            {
                $init_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
            }

    Tell them that it throws a warning: Warning: mcrypt_get_iv_size(): Module initialization failed.  Then ask if something is wrong with the mcrypt library- as there’s nothing inherently wrong with the code itself.

    I mean- we can hack around it, but we shouldn’t have to.  And we really don’t want to.  The best option is to get mycrypt working as expected.

    Make sense?

  • #7 / Oct 22, 2008 12:16pm

    hartmutd

    5 posts

    😊 O.k., I will do my very best with them. By the way, the CAPTCHA-problem is also solved, everythings working fine. About the ‘mcrypt_get_iv_size’-problem I’ll keep you informed. Thanks again…

  • #8 / Oct 22, 2008 12:19pm

    Robin Sowell

    13255 posts

    W00t!  We’re getting there.  But yes- I don’t want you to have to hack the file every upgrade.  Getting that working properly server side is definitely the best option.  Let us know how it goes.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases