68 Classifieds Forums

Email notify users of new or modified listing

This is a discussion on Email notify users of new or modified listing within the v3.1 Modules & Modifications forums, part of the v3.1 Legacy Help & Support category; I've seen a few posts on this issue, and some requests for this functionality, but no resolution. I think I've ...


Go Back   68 Classifieds Forums > v3.1 Legacy Help & Support > v3.1 Modules & Modifications

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 06-20-2007, 03:14 AM
Member
 
Join Date: May 2007
Posts: 37
Rep Power: 7
abkeller is on a distinguished road
Default Email notify users of new or modified listing

I've seen a few posts on this issue, and some requests for this functionality, but no resolution. I think I've got it narrowed down to which lines of code need to be modified, but am not certain of the syntax/command to make it work.

I want all users who submit a new ad, or modify an existing ad, to receive the confirmation email with the link to their ad detail page once they've completed the process. As the software is built, only the administrator receives these notifications, which doesn't make sense. I don't care if someone has posted, much less modified an ad, but I'll bet my users/sellers would like to get this auto notification.

I've been trying to pin down where exactly in the code I need to make what should be a simple change to change the email-to FROM the default admin email TO the user email.

I found this line in the usermodifylistings.php;

$mail->AddAddress(ADMIN_EMAIL);

I want to change this to the user email, but this syntax (from the userjoin.php file) doesn't work;

$mail->AddAddress($_POST['email']);

In the contact.php form the line looks like this;

$mail->AddAddress($to);

but that doesn't work on the usermodifylistings.php

Also, I can't find the send email subroutine anywhere in the usercheckout.php file. Am I missing something? I need to modify this process to send the confirmation email to the user. Where do I do that?

HELP, PLEASE!! I'm going bald...

__________________
private signature
68Classifieds - Developer Edition, v.3.1.7
Reply With Quote
  #2  
Old 06-20-2007, 11:44 AM
civ's Avatar
civ civ is offline
Senior Member
 
Join Date: Mar 2006
Location: Greer, SC
Posts: 664
Rep Power: 25
civ will become famous soon enough
Default

The reason replacing ADMIN_EMAIL with $_POST['email'] isn't working is because 'email' is not part of POST on userbrowselistings like it is in userjoin. You'll need to add an SQL query to get the email address of the user who is doing the editing. (and btw, $userid is an already-safe and in-scope variable to use for this)
__________________
Civ's Modules (____NOW v4 COMPATIBLE____):

» Stop Incomplete Listings! (proven revenue booster!)
» Scam Filter (Just say no to Nigerians!) updated
» Similar Listings (keep visitors longer)
» Feedback Mod (testimonial builder)
» Listing Status Reminder free!
Reply With Quote
  #3  
Old 06-20-2007, 08:53 PM
Member
 
Join Date: May 2007
Posts: 37
Rep Power: 7
abkeller is on a distinguished road
Default EMail notify still not working

I insterted the following SQL query into the modifylisting.php and the site seems to be working (I'm not getting any "failed query" error msgs), but the email is not being sent.

Here is the snippet of code...
//get the mail template

$sSQL="SELECT eID, eName, eSubject, eHTML, eText FROM ".PREFIX."email_templates WHERE eID=7";
$result=$db->query($sSQL);
$rs=$result->fetch();
$subject=$rs['eSubject'];
$htmlContent=$rs['eHTML'];
$textContent=$rs['eText'];
$sSQL="SELECT title,price FROM ".PREFIX."products WHERE id=".$productid;
$result=$db->query($sSQL);
$rs=$result->fetch();
$emailmessage.= $htmlContent.'<br>'. LANG_TITLE.": ".safeStripSlashes($rs['title'])."<br>\n";
$emailmessage.= LANG_PRICE .": ".FormatCurrency($rs['price'])."<br>\n";
$emailmessage.= "<a href='".URL."/viewlisting.php?view=".$productid."'>".URL."/viewlisting.php?view=".$productid."</a><br>\n";

//my inserted code
$sSQL="SELECT email FROM ".PREFIX."users WHERE id=".$userid;
$result=$db->query($sSQL);
$rs=$result->fetch();
$email=$rs['email'];



// Instantiate mail class
$mail = new Mailer();
$mail->AddAddress = $email;
$mail->Subject = $subject;
$mail->Body = $emailmessage;
$mail->AltBody = strip_tags($emailmessage);

What am I missing here?
__________________
private signature
68Classifieds - Developer Edition, v.3.1.7

Last edited by abkeller; 06-20-2007 at 09:14 PM.
Reply With Quote
  #4  
Old 06-21-2007, 01:27 PM
civ's Avatar
civ civ is offline
Senior Member
 
Join Date: Mar 2006
Location: Greer, SC
Posts: 664
Rep Power: 25
civ will become famous soon enough
Default

Echo out $email once you've pulled it out of $rs and let's see what you get.
__________________
Civ's Modules (____NOW v4 COMPATIBLE____):

» Stop Incomplete Listings! (proven revenue booster!)
» Scam Filter (Just say no to Nigerians!) updated
» Similar Listings (keep visitors longer)
» Feedback Mod (testimonial builder)
» Listing Status Reminder free!
Reply With Quote
  #5  
Old 06-21-2007, 03:36 PM
Member
 
Join Date: May 2007
Posts: 37
Rep Power: 7
abkeller is on a distinguished road
Default Next step...

I inserted the echo statement in here;

//now send email notification to user
$sSQL="SELECT email FROM ".PREFIX."users WHERE id=".$userid;
$result=$db->query($sSQL);
$rs=$result->fetch();
$email=$rs['email'];
---> echo "The value of email is:".$email; <-------

When I try to test the "Modify Listing" feature on my site, the email message at the top of the screen is "The value of email is: useremail@domain.com"

I logged in as the admin, which has the email account (email deleted) as the contact email, then I created a testing account with another email address as the contact email. Testing the modify ad feature after logging into BOTH accounts displays the correct contact email address.

It appears to be capturing the correct email address, but it's not sending the email to the user. What else am I missing?
__________________
private signature
68Classifieds - Developer Edition, v.3.1.7

Last edited by abkeller; 09-15-2007 at 06:33 PM. Reason: hide email
Reply With Quote
  #6  
Old 06-21-2007, 11:24 PM
Member
 
Join Date: May 2007
Posts: 37
Rep Power: 7
abkeller is on a distinguished road
Default Modify notification is now working, but not new listing

I found the problem with the code in the usermodifylistings.php

This;

$mail->AddAddress = $email;

Needed to be changed to this;
$mail->AddAddress ($email);

Now it works great.

I still need to be able to have the new listings notification sent to the USER not the admin. The code is setup differently in the usercheckout.php function.

The instatiate mail class code looks like this;
$mail = new Mailer();
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $htmlContent;
$mail->AltBody = $textContent;
$mail->AddAddress($_POST['email']);
$mail->AddAddress($to);
$mail->Send();

If I just add this line to the above code;

$mail->AddAddress($email);

It sends notification to the user email account, but it doesn't include the linked URL to the user listing. It also sends TWO copies of the same email to the user email address.

What is happening here?;

$mail->AddAddress($_POST['email']);

This line will send the new listing notify to ADMIN_EMAIL and grabs the linked URL and listings details. Where/how is it getting this information?
__________________
private signature
68Classifieds - Developer Edition, v.3.1.7
Reply With Quote
  #7  
Old 06-29-2007, 03:24 AM
Member
 
Join Date: May 2007
Posts: 37
Rep Power: 7
abkeller is on a distinguished road
Default Success! Users now receive auto notify for NEW listings

I figured out the source of the code which controls the auto email notify for NEW listings that go to admin. It's not in usercheckout.php, but here;

(root directory of 68 Classifieds)/includes/functions.php

By commenting out this line of code we can remove the embedded URL that goes to the admin link (which users don't need to see);

//should we email?
if($notification=="Y")
{
$sSQL="SELECT eID, eName, eSubject, eHTML, eText FROM ".PREFIX."email_templates WHERE eID=6";
$result=$db->query($sSQL);
$rs=$result->fetch();
$subject=$rs['eSubject'];
$htmlContent=$rs['eHTML'];

$sSQL="SELECT title,price FROM ".PREFIX."products WHERE id=".$orderid;
$result=$db->query($sSQL);
$rs=$result->fetch();
$emailmessage.= $htmlContent.'<br>'. LANG_TITLE.": ".safeStripSlashes($rs['title'])."<br>\n";
$emailmessage.= LANG_PRICE .": ".FormatCurrency($rs['price'])."<br>\n";
$emailmessage.= "<a href='".URL."/viewlisting.php?view=".$orderid."'>".URL."/viewlisting.php?view=".$orderid."</a><br>\n";
// Commented out
//$emailmessage.= "<a href='".URL."/administration/listinginfo.php?view=".trim($orderid)."'>".URL."/administration/listinginfo.php?view=".trim($orderid)."</a>";


Then, change the sendmail script to call the user ID and associated email from the dB and use it to populate the "To" field of the email;

$mail = new Mailer();
$mail->Subject = $subject;
$mail->Body = $emailmessage;
$mail->AltBody = strip_tags($emailmessage);

// Comment out the call to ADMIN_EMAIL
// $mail->AddAddress($Core->settings['email']);



$sSQL="SELECT email FROM ".PREFIX."users WHERE id=".$_SESSION['uid'];
$result=$db->query($sSQL);
$rs=$result->fetch();
$xemail = $rs['email'];

$mail->AddAddress("$xemail");
if(!$mail->Send())


Works like a charm!
__________________
private signature
68Classifieds - Developer Edition, v.3.1.7
Reply With Quote
  #8  
Old 06-29-2007, 05:06 AM
civ's Avatar
civ civ is offline
Senior Member
 
Join Date: Mar 2006
Location: Greer, SC
Posts: 664
Rep Power: 25
civ will become famous soon enough
Default

I'm glad you got it working Elizabeth, and thanks for posting your findings for others who may wish to do this as well.
__________________
Civ's Modules (____NOW v4 COMPATIBLE____):

» Stop Incomplete Listings! (proven revenue booster!)
» Scam Filter (Just say no to Nigerians!) updated
» Similar Listings (keep visitors longer)
» Feedback Mod (testimonial builder)
» Listing Status Reminder free!
Reply With Quote
  #9  
Old 07-03-2007, 06:37 AM
frommarcq's Avatar
Senior Member
 
Join Date: Mar 2006
Location: Lille (France)
Posts: 118
Rep Power: 14
frommarcq is on a distinguished road
Thumbs up

Thanks Elisabeth for this useful modification.

My wish is a little more complicated : I manually validate the ads. It would be great to send an email to the member when his/er ad has been accepted/refused.

I think the modifications will be placed in 'administration/modifylisting.php', but don't know what to insert... PHP and I aren't good friends... lol

I only know that 'checkoutDisURL' has to be on 'Y', and display from 'N' to 'Y'. It's a beginning !

Regards

Pascal
__________________
68classifieds (V4.0.9Developer)
Reply With Quote
  #10  
Old 07-03-2007, 05:23 PM
Member
 
Join Date: Dec 2006
Posts: 96
Rep Power: 10
objelland is on a distinguished road
Default

Hi All
I would really like to have a solution as frommarcq describes too.
If anyone takes the bother to help us out, it will be greatly appreciated.
Thanks!

Regards,
Oyvind
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Modification: Civs Feedback for emailing users that delete a listing civ v3.1 Modules & Modifications 1 05-25-2008 09:16 PM
Email all registered users brian-bear v3.1 Questions & Support 3 11-23-2006 10:27 AM
'Users Awating Email Confirmation’ group. SkGold v3.1 Suggestions and Feedback 2 07-18-2006 05:30 PM
Direct link to user listing in contact email SkGold v3.1 Questions & Support 2 07-10-2006 03:42 PM
Phpnewads munky20 v3.0 Questions & Support 10 03-30-2006 07:59 PM


All times are GMT -4. The time now is 02:58 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22