- Posts: 6
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Automatic Token Generation/Email
- burmat
- Topic Author
- Offline
- New Member
Less
More
12 years 5 months ago #69461
by burmat
Automatic Token Generation/Email was created by burmat
Good afternoon LimeSurvey users/devs. First let me start by saying I am new to LimeSurvey, but I am enjoying my time customizing and tweaking it for the need of my company. You guys are hard workers and created a great product that users like myself appreciate.
While I did search to find an answer to my question, my answer seems spread out throughout the world wide web and I would rather build something as up-to-date as possible.
I have a database that stores what is sold to customers and when. Everyday, I want to be able to run a script that will query this DB and pull all customers that have bought a product exactly 2 weeks prior. For each of these results (customer name, email, product purchased, etc..) I would like a token to be automatically generated and emailed to the customer. Querying the customer DB and inserting to the token DB is no problem, it's the auto-sending emails that I need ideas for.
I am looking for ideas on where to start. I have no problem creating the scripts to accomplish my goals, I would just like to hear from other users/devs and see if you have something similar or if there is a good place to start.
Thanks again LimeSurvey!
While I did search to find an answer to my question, my answer seems spread out throughout the world wide web and I would rather build something as up-to-date as possible.
I have a database that stores what is sold to customers and when. Everyday, I want to be able to run a script that will query this DB and pull all customers that have bought a product exactly 2 weeks prior. For each of these results (customer name, email, product purchased, etc..) I would like a token to be automatically generated and emailed to the customer. Querying the customer DB and inserting to the token DB is no problem, it's the auto-sending emails that I need ideas for.
I am looking for ideas on where to start. I have no problem creating the scripts to accomplish my goals, I would just like to hear from other users/devs and see if you have something similar or if there is a good place to start.
Thanks again LimeSurvey!
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
12 years 5 months ago #69504
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Automatic Token Generation/Email
I have coded a cronjob script which is run daily and send invitations/reminders to people listed at the token table of a predefined survey.
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- burmat
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
12 years 5 months ago #69517
by burmat
Replied by burmat on topic Automatic Token Generation/Email
Thanks for your response Mazi! I almost have that wrapped up. Because I have the survey on a different domain and server, I am exporting all of my customers to .CSV, uploading the file to the survey server, and I have my cronjob (almost complete) reading all .CSV files in a directory into the token table.
I don't really know where to start with the automatic emails though... Can you give me some hints on where to look first?
Thanks again,
-Nate
I don't really know where to start with the automatic emails though... Can you give me some hints on where to look first?
Thanks again,
-Nate
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
12 years 5 months ago #69523
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Automatic Token Generation/Email
Have a look at /admin/tokens.php ~ line 1400:
"if ($subaction == "email" && bHasSurveyPermission($surveyid, 'tokens','update'))"
At the end of that section the email is send:
"elseif (SendEmailMessage($oMail, $modmessage, $modsubject, $to , $from, $sitename, $ishtml, getBounceEmail($surveyid),null,$customheaders))"
So you should be able to use "SendEmailMessage()" at your cronjob.
"if ($subaction == "email" && bHasSurveyPermission($surveyid, 'tokens','update'))"
At the end of that section the email is send:
"elseif (SendEmailMessage($oMail, $modmessage, $modsubject, $to , $from, $sitename, $ishtml, getBounceEmail($surveyid),null,$customheaders))"
So you should be able to use "SendEmailMessage()" at your cronjob.
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- burmat
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
12 years 5 months ago #69526
by burmat
Replied by burmat on topic Automatic Token Generation/Email
Great I'll check it out tomorrow when I get back to work. Thanks for the help Mazi!
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
12 years 5 months ago #69555
by Mazi
If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.
Without your help we can't keep this project alive.
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Automatic Token Generation/Email
You're welcome!burmat wrote: Great I'll check it out tomorrow when I get back to work. Thanks for the help Mazi!
If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.
Without your help we can't keep this project alive.
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- burmat
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
12 years 5 months ago #69647
by burmat
Replied by burmat on topic Automatic Token Generation/Email
Mazi,
I have a few more questions if you do not mind. How do I retrieve the email template format to use for my .php script? I am using SendEmailMessage() no problem, but I want to be able to customize the email template through LimeSurvey and use it in my custom script. I see a lot of functions that handle the email template and the preparation of the email, but I cannot find a clear cut stem to the source and how to handle them.
If you have any other tips or pointers on where I should look first, I would be very grateful.
- Nathan
I have a few more questions if you do not mind. How do I retrieve the email template format to use for my .php script? I am using SendEmailMessage() no problem, but I want to be able to customize the email template through LimeSurvey and use it in my custom script. I see a lot of functions that handle the email template and the preparation of the email, but I cannot find a clear cut stem to the source and how to handle them.
If you have any other tips or pointers on where I should look first, I would be very grateful.
- Nathan
The topic has been locked.
- burmat
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
12 years 5 months ago #69649
by burmat
Replied by burmat on topic Automatic Token Generation/Email
Edit:
I think I have found what I was looking for. The table that the email templates are stored in is 'lime_surveys_languagesettings' (tricky name) and I found it by looking through /admin/editemailtemplates.php (look at $esquery). I don't quite know how I am going to handle it but I will post back with my results and scripts I built.
Again, any tips would be greatly appreciated.
- Nathan
I think I have found what I was looking for. The table that the email templates are stored in is 'lime_surveys_languagesettings' (tricky name) and I found it by looking through /admin/editemailtemplates.php (look at $esquery). I don't quite know how I am going to handle it but I will post back with my results and scripts I built.
Again, any tips would be greatly appreciated.
- Nathan
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
12 years 5 months ago #69651
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Automatic Token Generation/Email
It is stored at that weirdly namd table because there can be different versions, depending on the language.
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The following user(s) said Thank You: burmat
The topic has been locked.
- burmat
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
12 years 5 months ago - 12 years 5 months ago #69708
by burmat
Replied by burmat on topic Automatic Token Generation/Email
Ahh that clears it up.
Well thanks for the help Mazi. I attached the script I made below for anyone who wants to use/modify/look at it. One thing that I had to disable that I really didn't want to was the $subject encoding within the SendEmailMessage() function in /common_functions.php. I ended up stripping it away because sending an email from the script was making my subject gibberish and would not decode properly. If anyone has any tips on how to solve this problem so that I could put it back, I would be very grateful.
This script is a very rough draft but feel free to do whatever you want with it. Just to be clear, the script will:
- Read a directory that has .csv files in it.
- For every .csv file, it will import the fields into the tokens table and rename the files to .old so keep them but make them invisible to the script in the future
- It will then get the email template and values, and for each person in the tokens table that has not had an email sent, it will email them and update the sent time
!!NOTE #1: My .csv files *DO NOT HAVE HEADERS* and the columns are: firstname, lastname, email, emailstatus, token (automatically generated at the creation of .csv file), language
!!NOTE #2: When you see '< >' insert your own information. Do a search before you run the file for '<' and '>' symbols to verify you got them all.
Well thanks for the help Mazi. I attached the script I made below for anyone who wants to use/modify/look at it. One thing that I had to disable that I really didn't want to was the $subject encoding within the SendEmailMessage() function in /common_functions.php. I ended up stripping it away because sending an email from the script was making my subject gibberish and would not decode properly. If anyone has any tips on how to solve this problem so that I could put it back, I would be very grateful.
This script is a very rough draft but feel free to do whatever you want with it. Just to be clear, the script will:
- Read a directory that has .csv files in it.
- For every .csv file, it will import the fields into the tokens table and rename the files to .old so keep them but make them invisible to the script in the future
- It will then get the email template and values, and for each person in the tokens table that has not had an email sent, it will email them and update the sent time
!!NOTE #1: My .csv files *DO NOT HAVE HEADERS* and the columns are: firstname, lastname, email, emailstatus, token (automatically generated at the creation of .csv file), language
!!NOTE #2: When you see '< >' insert your own information. Do a search before you run the file for '<' and '>' symbols to verify you got them all.
Attachments:
Last edit: 12 years 5 months ago by burmat.
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
12 years 4 months ago #69741
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Automatic Token Generation/Email
Thanks for your feedback.
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
10 years 9 months ago #97649
by Mazi
Automatically sending Limesurvey invitation emails via cronjob: www.limesurvey-templates.com/automatical...nvitations-p-49.html
Automatically sending Limesurvey reminder emails via cronjob: www.limesurvey-templates.com/automatical...-reminders-p-45.html
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Automatic Token Generation/Email
Finally the Limesurvey cronjob scripts for sending email invitations and sending email reminders are available for Limesurvey 2:Mazi wrote: I have coded a cronjob script which is run daily and send invitations/reminders to people listed at the token table of a predefined survey.
Automatically sending Limesurvey invitation emails via cronjob: www.limesurvey-templates.com/automatical...nvitations-p-49.html
Automatically sending Limesurvey reminder emails via cronjob: www.limesurvey-templates.com/automatical...-reminders-p-45.html
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.