MODIFICATION: Receive a copy of the email sent from visitors to listing owners.

Discussion in 'Modules / Plugins / Modifications' started by cwp, Apr 4, 2008.

  1. cwp Customer

    Ever wanted to monitor messages that are sent from the contact form through the listing pages? I do this myself to monitor spam send to listing owners. I also use these emails to count how many messages were sent from website visitors each month. This is how I monitor conversions.

    You need the developer edition to do this modification.

    Open contact.php. Its located yourdomain.com/contact.php

    Find this:
    Code:
    $msg=$Mailer->sendMail($to, $content, $vars);
    Add this right after it:
    Code:
    //now make a copy for the admin
    $to="[email protected]";
    $content="contactownercopy.tpl";
    $msg=$Mailer->sendMail($to, $content, $vars);
    Replacing your email with [email protected]

    Notice that the email you receive will be the template "contactownercopy.tpl". You will need to upload this template to your email template folder.

    You can use the template I made shown below. It is a slightly modified copy of contactowner.tpl

    Code:
    {assign var='subject' value='New message sent from your website'}
    {include file="emails/html/mail_header.tpl"}
    <h2>New Message</h2>
    Hi Admin,
    <p>The following message has been sent to the listing owner from a visitor on your website.</p>
    <div class="hr"><hr /></div>
    <strong>Name:</strong> {$name}<br />
    <strong>Email:</strong> {$fromemail}<br />
    <strong>Message:</strong><br />
    {$comments}<br /><br />
    <strong>Listing URL: </strong><a href="{$listing_url}">{$listing_url}</a>
    <div class="hr"><hr /></div>
    <br />
    {include file="emails/html/mail_footer.tpl"}
    
  2. archavir Customer

    I've tried this on my site, but doesn't seem to forward the copy. Any other settings I have to touch-up on back-end maybe?
  3. cwp Customer

    Did you upload the new template? Without having a template you won't receive anything.
  4. paulsra Customer

    hi,
    i need to implement this operation in 3.1 but i dont have "$msg=$Mailer->sendMail($to, $content, $vars);"
    or part thereof in my contact.php.

    can this be done in ver 3.1 dev?

    thanks
  5. martso Customer

    Hi,
    I was wondering is there any way to get the IP of the sender and then block the IP somehow if the messages were spam or scam?
    Thanks
  6. cwp Customer

    In version 3 its all different code. Theres a way to do this in version 3.. Please thank Mike-N-Tosh for this:

    I believe this is as simple as this. Open your "contact.php" file and around line 121 you should see this:
    Code:
    $mail = new Mailer();
    $mail->AddAddress($to);
    $mail->From = $from;
    $mail->FromName = $name;
    $mail->Subject = $subject;
    $mail->IsHTML(true);
    $mail->Body = $htmlContent;
    $mail->AltBody = $textContent;
    
    Just add a line to this like this:
    Code:
    $mail->AddBCC("email@yourdomain");
    
    Obviously, changing the email address to the email address that you want it sent to. This won't send a different email to you, but a copy of the original email to you BCC so no one else see's it's being sent to you or the email address.

    I do this same thing, but for the user registration (userjoin.php) so that we know when a new user signs up.
  7. cwp Customer

    Not sure, you'll have to hire someone to custom code this in for you.
  8. paulsra Customer

    thats perfect, thanks mike-n-tosh, and CWP.

    userjoin sounds like a good ider as well, do you get both emails when someone joins up?
    i tried it and it woks great!

    thanks
  9. goin4savvy Customer

    Hi,
    I followed all of the instructions and this is the error that I got in my email box.

    Warning: Smarty error: unable to read resource: "emails/html/modifylisting.tpl" in /var/www/vhosts/naturalhorseforsale.com/httpdocs/includes/classes/smarty/Smarty.class.php on line 1095

    Anything I can do? I did create and upload the template as stated.

    Thanks,
    Jill B
  10. cwp Customer

    I'll look into this once I'm able to view my website (dns). It's possible this won't work with the newest version.
  11. crystal Customer

    Is there a way to do the same thing in reverse? I need to send a copy to the customer of an email that is sent by the system to the admin. The email I want to cc to the customer is the "new order" email - it is currently only sent to the admin. The customer gets no receipt of their order after placing an ad, so I want to modify the email template to be a receipt and send to both admin and customer.

    If this is possible I would appreciate the help!

    Thank you
  12. cwp Customer

    I checked the code I posted (my first post) for version 4x and compared it with the code thats on my copy of contact.php and it's the same. I also tested it again, and it works for me. I'm not sure why it won't work for you guys. Did "anyone" get it to work?

    The code I posted several posts down was untested, which was for version 3x. Not sure which one was giving you guys errors.
  13. cwp Customer

    Crystal,
    This was something I suggested (an email that is sent to the customer) after they order a listing for version 4.01 but wasn't put in. Maybe in the future it will be put in.
  14. goin4savvy Customer

    Thanks so much!

    Jill B
  15. HotAir Customer

    Yes, it works for me...
  16. MrGForce Customer

    Just wondering if this email notification would work in v4.1.3.

    It looks like the first post, by cwp, that indicates putting the sendmail code in the contact.php file, and creating and uploading the contactownercopy.tpl, will send a modified copy to the admin when someone contacts a lister. Would this same code work correctly in v4.1.3, or would there be any issues?

    Second, cwp also mentions in a later reply in this same post, that he also does this same thing, but for the user registration (userjoin.php) so that he knows when a new user signs up.

    In the v4.1.3 userjoin.php file, the code read as follows. Where and what would need to be added to make this also send a copy or BCC to the admin when someone registers?

    Thanks.

    ///////////////////////////////////////////////////////////////////////////////////

    //send email
    $to=trim($_POST['email']);
    $vars['firstname']=@$_POST['firstname'];
    $vars['lastname']=@$_POST['lastname'];
    $vars['username']=$_POST['username'];
    $vars['password']=$_POST['password'];

    $content="welcome.tpl";
    $errorText=$Mailer->sendMail($to, $content, $vars);

    if($level==3)
    {
    // Send confirmation email
    if ( $Register->sendConfirmation($id) )
    {
    $msg=LANG_USER_LOGIN_RESENT;
    $class_tpl->assign('title',$title);
    $class_tpl->assign('msg',$msg);
    $class_tpl->assign('body','user/userlogin.tpl');
    $class_tpl->display('layout.tpl');
    exit;
    }
    else
    {
    $errorText=LANG_MAIL_ERROR;
    }
    }
    else
    {
    $Login = new Login( $db );
    $Login->checkLogin(trim($_POST['username']), trim($_POST['password']), FALSE);
    $location="userindex.php";
    header("Location: $location");
    exit;
    }

    //////////////////////////////////////////////////////////////////////////////////////////////

    .

Share This Page