Be a Supporter!

JavaScript to send an email?

  • 409 Views
  • 5 Replies
New Topic Respond to this Topic
DroopyA
DroopyA
  • Member since: Dec. 10, 2002
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
JavaScript to send an email? 2004-10-13 17:27:19 Reply

Once again, my office has me doing a job that I'm not really qualified to do. Not that it's a problem, I love learning new things but this... this is just pissing me off.

What we have here, is a form with some basic fields. Name, Company, Email Address, and a Multi-Line text box. When they hit submit, my company wants all of the information on the form to be sent to their email address... using Javascript.

3 Questions:

1. Is this possible?
2. If not, what are my options to produce something similar?
3. How do I get JavaScript to send the email?

I've made it so that when the user hit's the "submit" button a JavaScript function is called that puts all of the information on the form into diffrent variables. It then builds a "mailto" string that reads something like:

'mailto:' + strEmailTo + '?SUBJECT=' + strSubject + '&?Body=Name: ' + strName + '&body=Company: ' + strCompany + '&Body=Email: ' + strEmailFrom + '&Body=Product: ' + strProduct + '&Body=Request: ' + strMessage;

I get no errors so everything is working... the question is, how do I get this mailto string to fire so that it actually sends the Email?


Request deletion
This went wrong.

liljim
liljim
  • Member since: Dec. 16, 1999
  • Offline.
Forum Stats
Staff
Level 28
Blank Slate
Response to JavaScript to send an email? 2004-10-13 17:48:57 Reply

Why JavaScript?

By the way; your ban message linked from your signature was most likely added because of a comment you made in a thread to Tanner, where you stated that there would be less banning/locking done because Wade had come online.

DroopyA
DroopyA
  • Member since: Dec. 10, 2002
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to JavaScript to send an email? 2004-10-13 18:04:36 Reply

At 10/13/04 05:48 PM, liljim wrote: Why JavaScript?

We don't have any web developers around here so we don't have any web programs. My boss is kind of an idiot and he knows for a fact I can use JavaScript without having to buy any 3rd party programs, compilers, or new resources on our web server.

Although, I've been doing some research and found 2 things.
1. It's not possible through JavaScript. The next best thing is to set the mailto string to a variable and then use Window.something.href=mailtoString. But from what I understood, that only works with Outlook... not an option.

2. When I loged in to our webserver using CuteFTP I saw that we had a CGI-Bin folder which says to me that we already have the abilty to run CGI Scripts without paying any more money. CGI would make this possible correct?

Of course now I have a diffrent problem. I know nothing about CGI. But that's ok... I can write brand new CGI scripts with notepad right? No special compiler required?

By the way; your ban message linked from your signature was most likely added because of a comment you made in a thread to Tanner, where you stated that there would be less banning/locking done because Wade had come online.

Yeah, but it's still stupid. All I did was make an observation about Tanner not locking every topic on the forum after Wade signed on. I didn't question his authority, nor was I posting in a spam topic... I did nothing wrong but still got banned. I email wade and about 6 hours later my ban was lifted... I just find the whole thing funny now. If it pisses you guys off I guess I can remove it for you but I kind of enjoy it.


Request deletion
This went wrong.

liljim
liljim
  • Member since: Dec. 16, 1999
  • Offline.
Forum Stats
Staff
Level 28
Blank Slate
Response to JavaScript to send an email? 2004-10-13 18:17:38 Reply

At 10/13/04 06:04 PM, DroopyA wrote:
At 10/13/04 05:48 PM, liljim wrote: Why JavaScript?
Although, I've been doing some research and found 2 things.
1. It's not possible through JavaScript.

That's why I asked.

2. When I loged in to our webserver using CuteFTP I saw that we had a CGI-Bin folder which says to me that we already have the abilty to run CGI Scripts without paying any more money. CGI would make this possible correct?

Of course. Have you checked to see whether you have PHP installed on the server you're using? Copy and paste to notepad, save as whatever.php, upload and access:

<?php echo "Hello World"; ?>

I only ask because this gives you even more options.

Anyway, there are many instances where you can just use a script written by someone else:

CGI
PHP

But that's ok... I can write brand new CGI scripts with notepad right?

Right. Or any other text editor you want to use.

DroopyA
DroopyA
  • Member since: Dec. 10, 2002
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to JavaScript to send an email? 2004-10-13 23:36:26 Reply

At 10/13/04 06:17 PM, liljim wrote: stuff

Nice, I'm at home right now so I can't run a test but I'm 98% sure that we have the ability to use PHP and the like. We use to have a "request information" page on our site that would do something real similar to what I need to do now.

My boss is a Phys-Ed major. He's only my boss by default and really knows nothing of programming. He told me it was all done in JavaScript but that's not possible... I assume he's just trying to sound smart and talking out his ass again. :( Thanks for the info though, I'm sure I'll be asking for your help again soon... I tried to avoide web programming but I guess now I have no choice. Pearl, here I come...


Request deletion
This went wrong.

CronoMan
CronoMan
  • Member since: Jul. 19, 2004
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to JavaScript to send an email? 2004-10-15 04:10:42 Reply

All you need is a SMTP server running on your server.

In php, the code for sending an E-Mail is simple; mail()
(I don't remember the parameters)

It is very important that you have your SMTP server running, or the mail function will not work.

I have never tried to send an email with ASP, but it can be done.


"no sound in ass"