js email form

Associate
Joined
20 May 2006
Posts
1,068
Hi guys,

I'm extremely new with this kind of thing, and just seeking some help.

I've obtain a free to use javascript form which is used to submit an email from a website. I'm trying to set the form up, but I've got no idea what section to edit to place in the SMTP the mail is sent from, and the email address it goes to.

I've looked through the code, and narrowed it down to line 73, I'm pretty certain this is the line which contains everything I need to edit.

Could someone have a look at line 73 of the below? Just need to know what part I put my email address in, the SMTP and the password for the SMTP address.

https://dl.dropboxusercontent.com/u/9850614/init.js

Thanks guys!
 
Associate
Joined
4 Feb 2011
Posts
580
Location
Halifax
You can't send emails using JavaScript, unless you're using Node.js which is run on the server side.

Your form submit function is here:

Code:
$form.find('.form-button-submit')
	.on('click', function() {
		$(this).parents('form').submit();
		return false;
	});

Which literally just submits the form for processing by the back-end. You need a back-end, which would handle the email sending.

If it's written in PHP, it usually looks something like:
Code:
$to = '[email protected]';
$subject = $_POST['subject'];
$message = $_POST['message'];
$from = $_POST['from'];
$headers = 'From: ' . $from . "\r\n";
mail($to, $subject, $message, $headers);

Though this won't let you send from a specified SMTP server and will use the mail server which is installed on the host.
 
Last edited:
Back
Top Bottom