Web to Customer Email Notification
  • Hi,

    Is there a way to have the admin account notified via email when a new customer registers via the Web to Customer add-on? This would be handy because I can't figure out how to have vTiger automatically add newly registered people to the portal and have to do it manually.

    Thanks for you help!
  • 18 Comments sorted by
  • hi johnkolbert,

    at present this feature is not available. if you have any specific requirements you can contact us.

    there is send_mail api (check sendreminder.php for using it) you can get the initial prototype working for this feature.

    regards,
    prasad
    vtiger team
  • so i found a work around that seems to fit what i needed. i'll leave what i did here incase anybody else was trying to do this.

    to have an email sent to you each time the form the web from is submitted using the "web forms" add-on:

    first, open the the "send_data.php" file of the webform you want to edit. you are looking for the following line of code:


    else
    {
    echo '<br><br>'.$result.'<br><br><a href="index.php">home</a>';
    }


    in the "contacts" send_data.php file this is lines 46-49. before the echo statement (but after the "else {") we are going to add the following code:

     
    $to = "admin@yoursite.com";
    $subject = "new contact added";
    $message = "a new contact has been added to vtiger via the web form";

    //mail headers
    $headers = "mime-version: 1.0\n";
    $headers .= "content-type: text/plain; charset=iso-8859-1\n";
    $headers .= "x-priority: 3\n";
    $headers .= "x-msmail-priority: normal\n";
    $headers .= "x-mailer: php\n";
    $headers .= "from: \"admin\" <admin@yoursite.com>\n";
    $headers .= "return-path: admin@yoursite.com\n";
    $headers .= "return-receipt-to: admin@yoursite.com\n";

    mail($to,$subject,$message,$headers);


    change the "admin@yoursite.com" to the desired email address, and change the message to whatever you like. normally this would be enclosed in php tags, but since you're pasting into a php page, there's no need. that's all it takes. it worked fine for me.

    i'm not sure how elegant of a solution this is, but it's better then no email i suppose. hope this helps someone!
  • thanks for this tip.

    i have just installed the webform inside a joomla! site and it was the first question i asked: how do i get notified that someone has submitted an entry?

    looking at your solution, i see how it works, but it makes the assumption that the webform is located on a server that supports email sending. this is not always going to be the case; the form could be running on a completely different system to that where vtiger resides. i'd really like vtiger to send the notice, not the webform component.

    anyway - many thanks again for the tip - i'm going to have a go at some hacking now and will publish my results as and when :-)

    cheers

    alan
  • o.k.

    i've "hacked" the webform for the lead part so far.

    i have done this in several stages.

    1. moved the stylesheet and javascript to separate files so that the whole webform is easier to deploy in cms type applications and elsewhere. you can re-locate the css and js files to a template folder for example.

    this means that it is also now easy to remove the "html, head and body tags of the webform index.php which will almost certainly be supplied by your existing web site.

    2. re-built the form so it is done in css. no tables. this makes it more flexible, will pass w3c validation and is better for accessibility.

    3. changed some of the fields of the lead form to be more "logical" imho. the form now collects first name:, last name:, company:, email:, telephone:, address:, city:, comments:. in that order. i made the first, last, email and company fields mandatory.

    4. modified the send_data.php file accordingly and added a function which send an email to a designated address on completion.

    5. modified the vtigercrm/soap/webform.php accordingly.

    it seems to me that this is all a bit of a dogs dinner. you are required to replicate the form structure and order in several places and at both "ends" of the connection. if i get some more time, i'll take a deeper look and see if it can be streamlined so you only need to define the field list in one place - config.php would be a good location i think.

    anyway, here's my index.php (leads):
    <?php
    /*********************************************************************************
    ** the contents of this file are subject to the vtiger crm public license version 1.0
    * ("license"); you may not use this file except in compliance with the license
    * the original code is: vtiger crm open source
    * the initial developer of the original code is vtiger.
    * portions created by vtiger are copyright (c) vtiger.
    * all rights reserved.
    *
    ********************************************************************************/

    if($error_message != '')
    echo '<span class="form_error">'.$error_message.'</span>';

    require_once('config.php');
    global $default_charset;

    ?>
    <!doctype html public "-//w3c//dtd html 4.01//en">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=<?php echo $default_charset ?>">
    <link rel="stylesheet" href="form.css" type="text/css" />
    <script type="text/javascript" language="javascript" src="validateform.js"></script>
    </head>
    <body>

    <form name="leadform" method="post" action="send_data.php">
    <input type="hidden" name="create" value="lead">
    <p>fields marked with a <span style="color:#d40000">*</span> are mandatory. all other fields are optional.</p>
    <fieldset><legend>enter your details</legend>
    <div class="notes">
    <h4>enter information</h4>
    <p class="last">please enter your contact details. blah blah blah...</p>
    </div>
    <div class="required">
    <label for="first_name">first name:</label>
    <input type="text" name="firstname" id="first_name" class="inputtext" size="30" maxlength="100" value="<?php echo $_post['firstname']?>" />
    </div>
    <div class="required">
    <label for="last_name">last name:</label>
    <input type="text" name="lastname" id="last_name" class="inputtext" size="30" maxlength="100" value="<?php echo $_post['lastname']?>" />
    </div>
    <div class="required">
    <label for="company">company:</label>
    <input type="text" name="company" id="company" class="inputtext" size="30" maxlength="100" value="<?php echo $_post['company']?>">
    </div>
    <div class="required">
    <label for="email">email:</label>
    <input type="text" name="email" id="email" class="inputtext" size="30" maxlength="100" value="<?php echo $_post['email']?>" />
    </div>
    <div class="optional">
    <label for="phone">telephone:</label>
    <input type="text" name="phone" id="phone" class="inputtext" size="30" maxlength="30" value="<?php echo $_post['phone']?>">
    </div>
    <div class="optional">
    <label for="address">address:</label>
    <input type="text" name="lane" id="address_1" class="inputtext" size="30" maxlength="100" value="<?php echo $_post['lane']?>" />
    </div>
    <div class="optional">
    <label for="city">city:</label>
    <input type="text" name="city" id="city" class="inputtext" size="30" maxlength="100" value="<?php echo $_post['city']?>" />
    </div>
    <div class="optional">
    <label for="comments">comments:</label>
    <textarea name="description" rows="2" cols="29"><?php echo $_post['description']?></textarea>
    </div>
    </fieldset>
    <fieldset>
    <div class="submit">
    <div>
    <input type="button" name="submit" value="submit »" class="inputsubmit" onclick="validateform();">
    <input type="submit" class="inputsubmit" value="cancel" />
    </div>
    </div>
    </fieldset>
    </form>

    </body>
    </html>


    i'll add the send_data.php in the next post to keep the length down.
  • here's the send_data.php (again for the lead webform)
    <?php
    /*********************************************************************************
    ** the contents of this file are subject to the vtiger crm public license version 1.0
    * ("license"); you may not use this file except in compliance with the license
    * the original code is: vtiger crm open source
    * the initial developer of the original code is vtiger.
    * portions created by vtiger are copyright (c) vtiger.
    * all rights reserved.
    *
    ********************************************************************************/

    include("config.php");
    require_once('nusoap/lib/nusoap.php');

    $client = new soapclient2($server_path."/vtigerservice.php?service=webforms", false,
    $proxyhost, $proxyport, $proxyusername, $proxypassword);
    $err = $client->geterror();

    if($_request['create'] == 'lead')
    {
    if(get_magic_quotes_gpc())
    {
    $firstname = stripslashes($_post['firstname']);
    $lastname = stripslashes($_post['lastname']);
    $company = stripslashes($_post['company']);
    $email = $_post['email'];
    $phone = stripslashes($_post['phone']);
    $city = stripslashes($_post['city']);
    $description = "webform : ".stripslashes($_post['description']);
    }
    else
    {
    $firstname = $_post['firstname'];
    $lastname = $_post['lastname'];
    $company = $_post['company'];
    $email = $_post['email'];
    $phone = $_post['phone'];
    $city = $_post['city'];
    $description = "webform : ".$_post['description'];
    }

    $params = array(
    'firstname' => "$firstname",
    'lastname' => "$lastname",
    'company' => "$company",
    'email' => "$email",
    'phone' => "$phone",
    'city' => "$city",
    'description' => "$description",
    'assigned_user_id' => "$assigned_user_id"
    );

    if($lastname != '' && $company != '')
    {
    $result = $client->call('create_lead_from_webform', $params, $server_path, $server_path);

    if($result['faultstring'] != '' && is_array($result))
    {
    echo '<br>'.$result['faultstring'];
    }
    else
    {
    send_email($params);
    echo '<br><br>'.$result.'<br><br><a href="index.php">home</a>';
    }
    }
    else
    {
    $error_message = "last name and company must be entered to create a lead.";
    include("index.php");
    }
    }
    else
    {
    include("index.php");
    }

    function send_email($arr) {
    $to = "yourname@youremail.com";
    $subject = "new lead recieved: " . $arr['company'];
    $message = "a new lead has been recieved on vtiger via the web form \n" .
    "--------------------------------------------------------\n" .
    "firstname: " . $arr['firstname'] . "\n" .
    "lastname: " . $arr['lastname'] . "\n" .
    "company: " . $arr['company'] . "\n" .
    "email: " . $arr['email'] . "\n" .
    "telephone: " . $arr['phone'] . "\n" .
    "city: " . $arr['city'] . "\n" .
    "comments: " . $arr['description'] . "\n\n";

    //mail headers
    $headers = "mime-version: 1.0\n";
    $headers .= "content-type: text/plain; charset=iso-8859-1\n";
    $headers .= "x-priority: 3\n";
    $headers .= "x-msmail-priority: normal\n";
    $headers .= "x-mailer: php\n";
    $headers .= "from: \"admin\" <$to>\n";
    $headers .= "return-path: $to\n";
    $headers .= "return-receipt-to: $to\n";

    mail($to,$subject,$message,$headers);
    }
    ?>


    i'll add the form.css next.
  • here's the form.css
    form {
    font-family: "liberation sans", tahoma, arial, sans-serif;
    margin: 0;
    padding: 0;
    min-width: 560px;
    max-width: 620px;
    width: 590px;
    }

    form fieldset {
    clear: both;
    border-color: #000000;
    border-width: 1px 0 0 0;
    border-style: solid none none none;
    padding: 10px;
    margin: 0;
    }

    form fieldset legend {
    font-size: 150%;
    font-weight: normal;
    color: #000000;
    margin: 0 0 0 0;
    padding: 0 5px;
    }

    label {
    font-size: 100%;
    }

    textarea {
    overflow: auto;
    }

    form div {
    clear: left;
    display: block;
    width: 354px;
    /*height: expression('1%');*/
    margin: 5px 0 0 0;
    padding: 1px 3px;
    }

    form fieldset div.notes {
    float: right;
    width: 158px;
    height: auto;
    margin: 0 0 10px 10px;
    padding: 5px;
    border: 1px solid #666666;
    background-color: #ffffe1;
    color: #666666;
    font-size: 88%;
    }

    form fieldset div.notes h4 {
    padding: 3px 0 3px 27px;
    border-width: 0 0 1px 0;
    border-style: solid;
    border-color: #666666;
    color: #666666;
    font-size: 110%;
    }

    form fieldset div.notes p {
    margin: 0em 0em 1.2em 0em;
    color: #666666;
    }

    form fieldset div.notes p.last {
    margin: 0em;
    }

    form div label {
    display: block;
    float: left;
    width: 130px;
    padding: 3px 5px;
    margin: 0 0 5px 0;
    text-align: right;
    }

    form div.optional label {
    font-weight: normal;
    }

    form div.required label {
    font-weight: bold;
    }

    form div select, form div textarea, form div input.inputtext {
    width: 200px;
    padding: 1px 3px;
    margin: 0 0 0 0;
    }

    form div.submit {
    width: 214px;
    padding: 0 0 0 146px;
    }

    form div.submit div {
    display: inline;
    float: left;
    text-align: left;
    width: auto;
    padding: 0;
    margin: 0;
    }

    form div input.inputsubmit, form div input.inputbutton, input.inputsubmit, input.inputbutton {
    background-color: #cccccc;
    color: #000000;
    width: auto;
    padding: 0 6px;
    margin: 0;
    }

    form div.submit div input.inputsubmit, form div.submit div input.inputbutton {
    float: right;
    margin: 0 0 0 5px;
    }

    form fieldset legend {
    line-height: 150%;
    }

    form input, form select, form textarea {
    background-color: #fff1ff;
    }

    form textarea.expanding {
    overflow: auto;
    overflow-x: auto;
    overflow-y: visible;
    }

    div.optional label:before {
    content: '';
    }

    div.required label:before {
    content: '* ';
    color:#d40000;
    }
  • you didnt include the js script you referenced, which was easy enough to solve. the main prob is for some reason the leads generated seem to go into the wrong fields. i get the email fine enough but for instance when viewing the lead in vtiger the email address is in the company field, first name is in last name and the last name is empty! what do you think could be mixing these up. i looked through your send_data.php and couldnt find the error. i am using vtiger 5.2
  • you didnt include the js script you referenced, which was easy enough to solve. the main prob is for some reason the leads generated seem to go into the wrong fields. i get the email fine enough but for instance when viewing the lead in vtiger the email address is in the company field, first name is in last name and the last name is empty! what do you think could be mixing these up. i looked through your send_data.php and couldnt find the error. i am using vtiger 5.2


    hi,

    iirc i didn't modify the javascript file. it only does some local field validation anyway.

    you must alter the field definitions on the vtiger host too. the file is vtigercrm-root-dir/soap/webforms.php

    the order and names of all the field must be identical at each end of the connection.

    regarding 5.2 i am unsure, we are using the up-to-date release 5.04. 5.2 will be some way off i guess ;-)

    hth

    alan
  • woops .. i forgot to change the webforms.php accordingly. one thing though, in your send_data.php there is no reference to the address field you added. so if someone gets stuck on that pull the address field out of the form or keep it and reference it in your send_data.php.

    i have to agree with your earlier point .. this does seem a bit spread around; but is certainly working. things could be a bit tighter in a future release i suppose.
  • woops again .. i am using 5.0.4 :)

    thanks for this very useful hack :!: and your quick response .. i think we were typing at the same time. lol
  • thank-you! this was extremely helpful for setting up an auto email for my lead web form as well... and i modified the same code to auto email me for quotes as well.

    :d
  • hi,

    the autoemails extension should be able to do this and a lot more.

    http://forge.vtiger.com/projects/autoemails/

    fyi
    joe
    tsolucio
  • hello,

    i have no idea about php files and all tat stuffs so can any one suggest me another way to solve the alert generate in crm?

    thank you.
  • although this thread is a bit old, i found it when looking for info on how to be notified when a webform has been posted into vtiger.

    i ended up coding my own solution that works great for our needs. i thought i'd post it here in case someone else can use it.

    in crm/modules/webforms/post.php, add the following code:

    require_once("modules/emails/mail.php");
    $subject = "[vtiger] new webform submission";
    $contents = "";
    foreach($userdata as $key=>$value) {
    if($key!='assigned_user_id') {
    $contents .= "$key = $value<br>\r\n";
    }
    }
    $status = send_mail ($module, getuseremailid('id',$ownerid), $user->user_name, '', $subject, $contents);


    this should be placed near the bottom of the file, immediately *after* the following line:

    $createresult = vtws_create($module,$userdata,$user);


    this will send an email to the defaultowner of webform submissions (per the webforms.config.php file). the email include the names & values of all form fields that were submitted.

    hth,
    m2
  • thanks for the information mrmelson; it seems to be the best post on this entire forum regarding email notifications.

    we have sugarcrm and vtiger loaded as test to see which one we are going to use and at least i can go back to tell my boss that vtiger can send notifications of a new webform. unfortunately it has taken me almost 6 hours to find this thread and test it.

    regards,

    keith
  • the vtiger is a great new way for sending notifications of a new webform. that is one of the best feature that i can consider. anyway, vtiger is one of my favorite option on my projects.
  • while doing research i have found the following code which configure the mail id to the customer mail id, if any one have suggestion or modification regarding to the email code than share.

    tcnwn.mynotifications = window.webkitnotifications;

    tcnwn.setup = function() {
    if(tcnwn.mynotifications.checkpermission() === 1) {
    // 1 = permission is uknown so we request permission
    tcnwn.mynotifications.requestpermission();
    } else if(tcnwn.mynotifications.checkpermission() === 0) {
    // 0 = permission has been granted to show notifications
    } else {
    // 2 = permission has been denied
    }
    };
  • johnkolbert- i tried with your workaround but it doesn’t seem to work. it is not always the case that the webform is located on a server that supports email sending. please explain how the mail service works in such a situation. thanks in advance.


    __________
    david fischer
    cheap car insurance for young drivers