Lunarpages Web Hosting Forum

Author Topic: TWebman's Custom email Scripts  (Read 4676 times)

leighsww

  • Guest
TWebman's Custom email Scripts
« Reply #15 on: February 16, 2004, 04:19:31 PM »
Okay, I just read the following thread regarding the cgi scripts, so hang on to your horses aqui_es1 before setting this up:

http://www.lunarforums.com/forum/viewtopic.php?t=11973

It seems that now any cgi, pl or php script extension can't be used for forms.  Maybe you should ask Danielle/Miraenda what script she's using as she has offered a replacement solution for chemic2.

Offline aqui_es1

  • Intergalactic Cowboy
  • *****
  • Posts: 59
TWebman's Custom email Scripts
« Reply #16 on: February 16, 2004, 05:31:31 PM »
Quote from: leighsww
Quote from: aqui_es1
I'll check out the links to the other threads that were given by leighsww.  I'm still a bit confused when using multiple forms though.

Eventually, certain forms would be going to different email addresses, not just one address and not just all email addresses one can point indentify in the email script.

How can I assign a script to a form or two, to go to a one particular email address only while having other forms on the website, being sent to other email addresses.


aqui_es1 - those other threads may really confuse you because they are super looooong.  If TWebMan's script doesn't do what you need (be able to assign different forms to be emailed to different recipients) then you may want to try the bnbform.cgi script.

You basically configure the "recipient" hidden tag in the hmtl form to a specific email addy.  So, each form can have a different recipient.

Am I reading your post correctly and is this what you are needing?

If it is, then go to bignosebird's site and download the script.  Here's the URL:

http://bignosebird.com/carchive/bnbform.shtml

Then follow the instructions, and if you run into problems, post here and I'll help you.

One last thing, on the bignosebird site there is a sample to see the script in action where he has two recipients in the form where you can click on to select which recipient you want to send the form results to.  Well, if you are only wanting the form sent to only "one" recipient automatically (where the customer doesn't have to select who to send to,) you can just assign the recipient's email addy in the form itself as a hidden tag.

Just thought I'd mention that in case you thought you had to have them check mark the recipient even if you only will be having one (and not two) recipients.  Anyway, once you read the documentation for the script you will get an idea of what you want to use.


Hi,
So can the script just be set up to send a couple of forms to a specific email address without having the Customer select where to send it to?  Most times, the customer won't know which email would be appropriate and I'd hate to burden them to make a choice, so to make the "customer experience" pleasant, I would like to set that up on the back-end so the customer would just click the "submit" button and they're done.

Thanks for all your help!  :yey:

Offline TWebMan

  • Quantum Encyclopedia Writer
  • *****
  • Posts: 3047
    • Take charge of your site
TWebman's Custom email Scripts
« Reply #17 on: February 16, 2004, 06:26:23 PM »
aqui_es, just want you to know that part of FormMail's vulnerablility is the variable recipient.

I know that's what you're trying to accomplish, but it doesn't have to be set as a variable before the post hits the script.

The script can easily select a recipient depending on the value of another field.

first of all what determines where the email goes?  Is there a 'subject' or 'purpose of message' menu they select from?

How many different possible recipients are there?

I can make something out of my script that will allow this, and still be secure as any recipient will be still hardcoded into the script.  Just let me know.
"Computers cause people to make more mistakes than any other invention in history, with the possible exception of handguns and tequila."  - Unknown
"Liberty of any kind is seldom lost all at once." - D. Hume
Every day is an Ode to Joy
The planet will be fine... and so will your site

leighsww

  • Guest
TWebman's Custom email Scripts
« Reply #18 on: February 16, 2004, 07:51:12 PM »
Quote from: aqui_es1
So can the script just be set up to send a couple of forms to a specific email address without having the Customer select where to send it to?


Yes, it would have, but just today there was an email that LP sent that said that the bnbform.cgi script can't be used anymore on their servers (I just received this email a few minutes ago).  So, basically, you have to scrap using this form script, now.

I, too, have to go now and change some of my forms that I still have using the bnbform.cgi to something else (other forms I have had Scanman20 convert to PHP for me).

Anyway, since we both now seem to be needing the same capability of different forms going to different recipients, let's see what TWebMan can do for us with what he said in his above post.

TWebMan - HELP!!  :love:

Basically, for what I configured for my sister's site, here's examples:

"Products Form" sends results to "products@domain.com"
"Auditions Form" sends to "auditions@domain.com"
"Tickets Form" sends to "tickets@domain.com"

etc.

Each form needs to have the recipient correlating to the form that is being filled so that it is forwarded to the particular person taking care of that department.

Offline aqui_es1

  • Intergalactic Cowboy
  • *****
  • Posts: 59
TWebman's Custom email Scripts
« Reply #19 on: February 16, 2004, 11:20:15 PM »
Yes!  This is exactly what I would need to do.   So, we'll wait for TWeb's replies?

I hope we can have something coming soon.

Sincerely,
aqui_es1

Offline TWebMan

  • Quantum Encyclopedia Writer
  • *****
  • Posts: 3047
    • Take charge of your site
TWebman's Custom email Scripts
« Reply #20 on: February 17, 2004, 02:58:32 AM »
Quote from: leighsww

"Products Form" sends results to "products@domain.com"
"Auditions Form" sends to "auditions@domain.com"
"Tickets Form" sends to "tickets@domain.com"

etc.....

"etc"    Second largest word in the language, besides "if".   :)

How many addresses?  Is it like 10, or like 100?  1000?  That's the first concern.

In the example above, the fom would have a drop menu, with those items:

"Products Form"
"Auditions Form"
"Tickets Form"

The script will then select from its own little list of recipients based on what it sees coming in from that drop menu.

The list you posted there, leighsww,  is exactly what I would need, but a real one of course, letting me know which selection needs to send where.  Just send it through my twebman home page (there's a form there) or PM me with it, however you like.

Same with you, aqui_es.  You guys have just given me an idea for a good enhancement that may cure this same dilema for many folks :)

If it is like hundreds of possible recipients, then we'd have to get a db involved, though I do like as much as possible to keep the recipients in the script.  That way the recipient never need come from an external source, and the script knows that, so it helps keep it secure from those bad, bad spammers!

BAD spammers!  :whip:
"Computers cause people to make more mistakes than any other invention in history, with the possible exception of handguns and tequila."  - Unknown
"Liberty of any kind is seldom lost all at once." - D. Hume
Every day is an Ode to Joy
The planet will be fine... and so will your site

leighsww

  • Guest
TWebman's Custom email Scripts
« Reply #21 on: February 17, 2004, 11:02:49 AM »
Quote from: TWebMan
"etc"    Second largest word in the language, besides "if".   :)


LOL!  Sorry, wasn't sure if exacts were needed in case we were going to need to add those ourselves to your script when you revised it.

Actually, I've already got the forms fixed last night as I had to get this done right away, so I'm all squared away for now.  Thanks, anyway!  :P

Offline TWebMan

  • Quantum Encyclopedia Writer
  • *****
  • Posts: 3047
    • Take charge of your site
TWebman's Custom email Scripts
« Reply #22 on: February 17, 2004, 11:30:39 AM »
Good deal :)  We'll see if aqui_es1 needs any help.  Let me know  :thumb:
"Computers cause people to make more mistakes than any other invention in history, with the possible exception of handguns and tequila."  - Unknown
"Liberty of any kind is seldom lost all at once." - D. Hume
Every day is an Ode to Joy
The planet will be fine... and so will your site

Offline aqui_es1

  • Intergalactic Cowboy
  • *****
  • Posts: 59
TWebman's Custom email Scripts
« Reply #23 on: February 17, 2004, 04:59:40 PM »
Quote from: TWebMan
Good deal :)  We'll see if aqui_es1 needs any help.  Let me know  :thumb:


Of course I would need some help  8-)

I would probably have about 2-3 seperate recepients each getting about 2 forms each.

I have a twister for you though, and don't have a heart attack, but some of the forms will be in Chinese  :shock:

Do you think that by naming the properties of the filed, button, etc. with an English name, would help the script identify the fileds and buttons?

The the text placed on the form itself  be in Chinese of course.

Whatta you think?

Offline shadowbane

  • Trekkie
  • **
  • Posts: 18
    • http://www.colberts.us
TWebman's Custom email Scripts
« Reply #24 on: February 17, 2004, 05:59:19 PM »
As an alternative to having the destination email address completely hardcoded in the script, how about having a list of possible email addresses in the script, and have the form specify something like destinationemail=1, then just use entry 1 from the array.

Also,

If the form is in a password protected directory
and If their email address is on your site
and if the directory-username matches their email address

you should be able to grab their user name from an environment variable to keep them from needing to enter it.  But thats a lot of ifs...  it would go something like this in PHP (of course I havent tested this, and my PHP is a little rusty):

Code: [Select]

<input name="YourEmail" type="text" value="<? echo $REMOTE_USER ?>@example.com" size="40">
ShadowBane

Offline shadowbane

  • Trekkie
  • **
  • Posts: 18
    • http://www.colberts.us
TWebman's Custom email Scripts
« Reply #25 on: February 17, 2004, 06:36:07 PM »
Im great at replying to myself... :D

another option:  The recipient domain could be hard coded and the dynamic portion could be heavily filtered..   ie:

perl:
Code: [Select]
recipient =~ /[^a-zA-Z0-9_]//g;
recipient .= '@example.com';


thus recipient="accounting" results in an email to accounting@example.com
and recipient="casualjoe@spamvictim.com" results in an email to casualjoespamvictimcom@example.com

That would limit spammers to the site with the form.
ShadowBane

Offline TWebMan

  • Quantum Encyclopedia Writer
  • *****
  • Posts: 3047
    • Take charge of your site
TWebman's Custom email Scripts
« Reply #26 on: February 17, 2004, 08:41:00 PM »
Two or three recipients?  That's it?

Why did I guess there might be an Oriental flavor to this?  I just had some sautéed gator.  It wasn't very good.  But my friend's fried gator was great!  Do they eat that over there?

Anyway, shadowbane, looks like some good solutions there.  He only has two possible recipients though, so I'd just do a couple of if's depending on a drop menu they'd select, just plugging in one of the possible recipient addies depending on the value of the drop menu.

aqui_es1, if you like, PM me with the recipients, and some matching value for each that the user would select out of a menu that would determine who they would go to.
"Computers cause people to make more mistakes than any other invention in history, with the possible exception of handguns and tequila."  - Unknown
"Liberty of any kind is seldom lost all at once." - D. Hume
Every day is an Ode to Joy
The planet will be fine... and so will your site

Offline aqui_es1

  • Intergalactic Cowboy
  • *****
  • Posts: 59
TWebman's Custom email Scripts
« Reply #27 on: February 18, 2004, 05:48:50 AM »
Ok TWebMan,

I'll PM u as soon as I get the details.  Would the Chinese text in the form affect the script at all?  Would the option of naming the fields' properties in English help?

As for the Gator meat, here in the South the locals joke when they say "we eat anything that flies, except an airplane and anything with four legs, except a table"   :)

Thanks -

Offline aqui_es1

  • Intergalactic Cowboy
  • *****
  • Posts: 59
TWebman's Custom email Scripts
« Reply #28 on: February 20, 2004, 07:23:18 PM »
Quote from: TWebMan
Ah, ok.  Well, the recipient email is hard-coded into the script, and that must remain, because that is one of the main security features of the script, keeping spammers from hijacking it like they do FormMail.

So, yes, if the email containing form field values is going to a different email, that would require a different script.  A different script for each recipient, but any forms that are to send to the same email, can use the same script.

Chillin in China, eh?  Cool.  Gotta make it over that way one day soon :)


Hey TWebMan,

If I could use different scripts, which would proabably be the best and quickest solution for now, how could i accomplish this?  

Would it be as simple as configuring the forms to a particular script and then save the script using different file names?

This is what was puzzling me at first, because the tutorials for cgimail want you to name the one script file a particular way and doesn't mention anything about having multiple mail scripts handling different forms.

If I can get this up and running this way, later we can look at customizing and simplifying the process using only one script.

Since some forms will have some Chinese flavor to them
 :thumb: , I noticed in a sample script an entry like this: $charset           = 'iso-8859-1';

Would I have to code these scripts to read Chinese Characters (Big5) so the output would be in Chinese?  This is what I want to happen.

let me know ok bud...

Offline TWebMan

  • Quantum Encyclopedia Writer
  • *****
  • Posts: 3047
    • Take charge of your site
TWebman's Custom email Scripts
« Reply #29 on: February 20, 2004, 08:59:41 PM »
Yeah, you could do what you are describing here, with different file names.

Pulling recipients out of an array still requires a variable for the recipient.

Again, I know that hard-coding the recip right into the sendmail command is the most secure.  Anything outside of that means that what will be in that sendmail command is a variable, and though there are ways to protect it, seems to me the best way is not to have a variable to protect at all.   Not in a scripting language like perl, anyway.

aqui_es1, if it's just a handful of recipients, it's not that difficult to code them into one script.  If you have a lot, you could always share the load amongst a couple of them or a few.
"Computers cause people to make more mistakes than any other invention in history, with the possible exception of handguns and tequila."  - Unknown
"Liberty of any kind is seldom lost all at once." - D. Hume
Every day is an Ode to Joy
The planet will be fine... and so will your site