Bienvenue, Invité
Nom d'utilisateur : Mot de passe : Se souvenir de moi
  • Page :
  • 1
  • 2

SUJET : Automatic Token Generation/Email

Automatic Token Generation/Email il y a 3 ans 5 jours #69461

  • burmat
  • Portrait de burmat
  • Hors ligne
  • Fresh Lemon
  • Messages : 7
  • Karma: 0
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!
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Automatic Token Generation/Email il y a 3 ans 3 jours #69504

  • Mazi
  • Portrait de Mazi
  • Hors ligne
  • LimeSurvey Team
  • Messages : 5423
  • Remerciements reçus 307
  • Karma: 252
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
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Automatic Token Generation/Email il y a 3 ans 3 jours #69517

  • burmat
  • Portrait de burmat
  • Hors ligne
  • Fresh Lemon
  • Messages : 7
  • Karma: 0
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
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Automatic Token Generation/Email il y a 3 ans 3 jours #69523

  • Mazi
  • Portrait de Mazi
  • Hors ligne
  • LimeSurvey Team
  • Messages : 5423
  • Remerciements reçus 307
  • Karma: 252
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.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Automatic Token Generation/Email il y a 3 ans 3 jours #69526

  • burmat
  • Portrait de burmat
  • Hors ligne
  • Fresh Lemon
  • Messages : 7
  • Karma: 0
Great I'll check it out tomorrow when I get back to work. Thanks for the help Mazi!
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Automatic Token Generation/Email il y a 3 ans 2 jours #69555

  • Mazi
  • Portrait de Mazi
  • Hors ligne
  • LimeSurvey Team
  • Messages : 5423
  • Remerciements reçus 307
  • Karma: 252
burmat écrit:
Great I'll check it out tomorrow when I get back to work. Thanks for the help Mazi!
You're welcome!

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
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Automatic Token Generation/Email il y a 3 ans 1 jour #69647

  • burmat
  • Portrait de burmat
  • Hors ligne
  • Fresh Lemon
  • Messages : 7
  • Karma: 0
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
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Automatic Token Generation/Email il y a 3 ans 1 jour #69649

  • burmat
  • Portrait de burmat
  • Hors ligne
  • Fresh Lemon
  • Messages : 7
  • Karma: 0
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
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Automatic Token Generation/Email il y a 3 ans 1 jour #69651

  • Mazi
  • Portrait de Mazi
  • Hors ligne
  • LimeSurvey Team
  • Messages : 5423
  • Remerciements reçus 307
  • Karma: 252
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
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
L'administrateur a désactivé l'accès en écriture pour le public.
Cet utilisateur a été remercié pour son message par: burmat

Re: Automatic Token Generation/Email il y a 3 ans 3 heures #69708

  • burmat
  • Portrait de burmat
  • Hors ligne
  • Fresh Lemon
  • Messages : 7
  • Karma: 0
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.

Fichier attaché :

Nom du fichier : import_csv.rar
Taille du ficher : 3 KB
Dernière édition: il y a 3 ans 3 heures par burmat.
L'administrateur a désactivé l'accès en écriture pour le public.
  • Page :
  • 1
  • 2
Modérateurs: ITEd
Temps de génération de la page : 0.151 secondes
Donation Image