After Updating field "email1" is not sent with the notification mail

Current Version:
Version 7.11.2
Sugar Version 6.5.25 (Build 344)

code:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>

<html lang='en_us'><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body><style type="text/css"><!--
form#WebToLeadForm, form#WebToLeadForm * {margin: 0; padding: 0; border: none; color: #333; font-size: 12px; line-height: 1.6em; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;}
form#WebToLeadForm {float: left; border: 1px solid #ccc; margin: 10px;}
form#WebToLeadForm h1 {font-size: 32px; font-weight: bold; background-color: rgb(60, 141, 188); color: rgb(247, 247, 247); padding: 10px 20px;}
form#WebToLeadForm h2 {font-size: 24px; font-weight: bold; background-color: rgb(60, 141, 188); color: rgb(247, 247, 247); padding: 10px 20px;}
form#WebToLeadForm h3 {font-size: 12px; font-weight: bold; padding: 10px 20px;}
form#WebToLeadForm h4 {font-size: 10px; font-weight: bold; padding: 10px 20px;}
form#WebToLeadForm h5 {font-size: 8px; font-weight: bold; padding: 10px 20px;}
form#WebToLeadForm h6 {font-size: 6px; font-weight: bold; padding: 10px 20px;}
form#WebToLeadForm p {padding: 10px 20px;}
form#WebToLeadForm input,
form#WebToLeadForm select,
form#WebToLeadForm textarea {border: 1px solid #ccc; display: block; float: left; min-width: 170px; padding: 5px;}
form#WebToLeadForm select {background-color: white;}
form#WebToLeadForm input[type="button"],
form#WebToLeadForm input[type="submit"] {display: inline; float: none; padding: 5px 10px; width: auto; min-width: auto;}
form#WebToLeadForm input[type="checkbox"],
form#WebToLeadForm input[type="radio"] {width: 18px; min-width: auto;}
form#WebToLeadForm div.col {display: block; float: left; width: 330px; padding: 10px 20px;}
form#WebToLeadForm div.clear {display: block; float: none; clear: both; height: 0px; overflow: hidden;}
form#WebToLeadForm div.center {text-align: center;}
form#WebToLeadForm div.buttons {padding: 10px 0; border-top: 1px solid #ccc; background-color: #f7f7f7}
form#WebToLeadForm label {display: block; float: left; width: 160px; font-weight: bold;}
form#WebToLeadForm span.required {color: #FF0000;}
--></style>
<!-- TODO ???
<script type="text/javascript" src='https://crm.cryston-web.com/cache/include/javascript/sugar_grp1.js?v=bD2adVtJuz5tolL_MYUUew'></script>
--><form id="WebToLeadForm" action="https://crm.cryston-web.com/index.php?entryPoint=WebToPersonCapture" method="POST" name="WebToLeadForm">
<h2>Web form to create Leads</h2>
<p>Submitting this form will create Leads</p>
<div class="row">
<div class="col"><label>Last Name: <span class="required">*</span></label><input name="last_name" id="last_name" type="text" required="" /></div>
<div class="col"> </div>
<div class="clear"> </div>
</div>
<div class="row">
<div class="col"><label>Email Address: </label><input name="email1" id="email1" type="email" />
<div class="col" style="padding-left: 0;"><input name="opt_in_email1_default" type="hidden" value="1" /> <label>Opt In:</label><input name="opt_in_email1" id="opt_in_email1" type="checkbox" /></div>
</div>
<div class="col"> </div>
<div class="clear"> </div>
</div>
<div class="row">
<div class="col"><label>Mobile: </label><input name="phone_mobile" id="phone_mobile" type="text" /></div>
<div class="col"> </div>
<div class="clear"> </div>
</div>
<div class="row center buttons"><input class="button" name="Submit" type="submit" value="Submit" onclick="submit_form();" />
<div class="clear"> </div>
</div>
<input name="campaign_id" id="campaign_id" type="hidden" value="ad5d970d-fa87-fa91-6673-5c7ace1b06b0" /> <input name="assigned_user_id" id="assigned_user_id" type="hidden" value="75de00d0-7c10-863a-2dbc-5c6750ba0bc4" /> <input name="moduleDir" id="moduleDir" type="hidden" value="Leads" /></form>
<p>
<script type="text/javascript">// <![CDATA[
    function submit_form() {
        if (typeof(validateCaptchaAndSubmit) != 'undefined') {
            validateCaptchaAndSubmit();
        } else {
            check_webtolead_fields();
            //document.WebToLeadForm.submit();
        }
    }

    function check_webtolead_fields() {
        if (document.getElementById('bool_id') != null) {
            var reqs = document.getElementById('bool_id').value;
            bools = reqs.substring(0, reqs.lastIndexOf(';'));
            var bool_fields = new Array();
            var bool_fields = bools.split(';');
            nbr_fields = bool_fields.length;
            for (var i = 0; i < nbr_fields; i++) {
                if (document.getElementById(bool_fields[i]).value == 'on') {
                    document.getElementById(bool_fields[i]).value = 1;
                } else {
                    document.getElementById(bool_fields[i]).value = 0;
                }
            }
        }
    }
// ]]></script>
</p></body></html>

When I fill out the form the following mail is sent:

Name: xxxxxxxxxx
Mail: !! no mail !!
Phone: xxxxxxxxxxx

Please login to your account and edit your new lead.

I checked the mail template

Name: $lead_last_name

Mail: $lead_email1

Phone: $lead_phone_mobile



Please login to your account and edit your new lead.

It seems everything is ok but I never receive the entered email.

Maybe the following thread can be of help:
https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/10259-web2lead-form-what-s-the-lead-email-variable-for-an-email-template

Hi I am sorry… i am not quite sure what to do. And the TS did not really say that your suggestions worked.

However i tried changing to $email1 but also $webtolead_email1 and none of them worked out. $lead_phone_mobile and the other one seem to work fine so why would I just change the mail?

Can you explain a bit more please?

  1. In which file do you compose and send the email?

  2. Please post the code where you compose and send the email

  3. What is the error?
    (I understand:
    a. you don’t receive the email
    b. the lead email address does not appear in the email (that you receive, so a. is not applicable)
    c. both: you don’t receive the email and the lead email is not set
    )

I have quickly dreated some code that sends an email when a web to lead is captured. Unfortnuately it isn’t upgrade safe.

I have edited the file: modules/Campaigns/WebToLeadCapture.php

To get all the fields of the form I add the following code:


$WA_email_string = substr($query_string, 1);
$WA_pairs = array();
$WA_pairs = explode("&", $WA_email_string);

$WA_My_email_message = "";
foreach ($WA_pairs as $WA_one_pair)
  {
      list($WA_this_key, $WA_this_value) = explode("=", $WA_one_pair);
      $WA_My_email_message .= $WA_this_key . ": " . htmlspecialchars(urldecode(trim($WA_this_value))) . "\r\n";

  }

// Prepare the email
$WA_From_email_address = "sender_email@address.com"; // edit the email address
$WA_From_header  = "From: SuiteCRM Web to lead form" . "<" . $WA_From_email_address . ">\r\n";;
$WA_email_subject = "New lead from SuiteCRM";
$WA_To_email_address =  "recipient_email@address.com"; // edit the email address

// Send the email
mail($WA_To_email_address, $WA_email_subject, $WA_My_email_message, $WA_From_header);

The piece of code above goes immediately after:


      if(empty($lead)) {
        if($first_iteration){
          $query_string .= $first_char;
        } else {
          $query_string .= "&";
        }
        $query_string .= "error=1";
      }

You can try with this code to try to understand what is happening. Maybe you can write a log to better debug.

hi @amariussi,

Thank you for your reply.

I was able to figure out what was the actual problem:

When I create a from and use the fields name, mail and mobile phone it als adds the opt-in for the mail.

I am using this form for another app that maps the information to the specific fields. However, in the app there is no option to tick or untick “opt-in” so everytime the form is sent, the mail is missing.

When I use it with the regular HTML Raw code it gives me the option to tick or untick the box for “opt-in” but even when I tick it, it sends the form without the mail to the admin and sends the opt-in to the usermail to take action. After opt-in of the user another mail is sent to the admin with the mailadress.

This was working before without any problems. Is there a way to make this work again?
Or to unless force the “tick” of the box?

Best regards and thx in advance

fyi: i read you answer :slight_smile: i am not ignoring it. I am on route and not able to test your solution. But maybe you have another solution based on the new information.