View Full Version : java code for mailing list
reekdog
02-09-2008, 12:51 AM
Hey,
I'm currently putting together a website and i'm wanting to include a mailing list subscription box. However, i don't really want to pay for one yet as for the first few months my mailing list will be small because during that time i'll slowly be increasing my traffic.
I'm wondering if anyone knows of a java (or other) code i can insert which will appear like a normal newsletter subscription box (enter e-mail address here, etc). Then when an e-mail address is entered, have that e-mail sent to my e-mail account so i can add them to my mailing list.
I know i can get one in .php but my hosting provider doesn't support .php, which is annoying.
If anyone knows of a code to use, or somewhere i can obtain it, that would be really appreciated.
I'm also looking for a java (or other) code which i can use for a mail script. Again, my hosting doesn't support .php and they seem to be the only codes i can find for this.
For this box i just want the following sections; name, e-mail address, contact(type e-mail), and then have this directed straight to my e-mail account to keep my e-mail address private.
Any help is appreciated, thanks.
rangana
02-09-2008, 12:58 AM
Hi reekdog!
First of all, Welcome! :banana::banana:
Anyway, this things could be made possible through a formmail script. You could give it a google for some free formmail script.. (http://bigbiz.net/faq/forms/forms.php)
See if it helps.:D
reekdog
02-10-2008, 12:24 AM
Thanks for your reply rangana.
I did a search for 'formmail script', and i could only find one which wasn't .php. If there where some other ones i couldn't find them on the site. The one i found was the following:
<form action="mailto:you@yourdmainhere.com" method="post" enctype="text/plain" >
FirstName:<input type="text" name="FirstName">
Email:<input type="text" name="Email">
<input type="submit" name="submit" value="Submit">
</form>
But i don't like its function because 1. An error appears when you click submit, which isn't a bad thing in terms of it not actually working, it just says "this form is being submitted.. blah blah". And 2. After i click OK on the error notice, another window pops up for Internet Connection Wizard (??), i don't know why this should happen, and another this may not happen on everyones computer, if it happens on mine it doesn't make me feel confident that it won't happen to everyone else wanting to sign up for my newsletter too.
Any other suggestions for finding one??
rangana
02-11-2008, 08:05 PM
Hi reekdog,
The reason why an internect connection wizard appears is because it tries to open a personal informatio manager like Microsoft Outlook or Lotus Notes.
It is because of your action which is "mailto"...
Have you given formmail script a google??..:D
reekdog
02-12-2008, 11:47 PM
I'm a bit slow in going to the link you provided.. sorry!
This is a code which is on the siteyou linked too, could you help me fill this in correctly?
<form action="http://www.bigbiz.com/cgi-bin/forms.cgi" method="POST">
Name: <input name=myname>
Email address: <input name=F_to>
<input type=hidden name=msg value="Thank you for using forms.cgi">
<input type=hidden name=yourname value="Your name is">
<input type=hidden name=F_fields value="yourname+myname,msg">
<input type=hidden name=F_subject value="forms.cgi test">
<input type=hidden name=F_from value="nobody@bigbiz.com (Form Test - Do not reply)">
<input type=submit value="Send">
</form>
Filled in demo:
<form action="http://www.bigbiz.com/cgi-bin/forms.cgi" method="POST">leave this as is?
Name: <input name=myname><input name=reekdog> ?
Email address: <input name=F_to> <input name=reekdog@email.com> ?
<input type=hidden name=msg value="Thank you for using forms.cgi">Do i change this to "thankyou for signing up to our newsletter, etc?
<input type=hidden name=yourname value="Your name is"> yourname value="reekdog"> ?
<input type=hidden name=F_fields value="yourname+myname,msg">what should i put here??
<input type=hidden name=F_subject value="forms.cgi test">Do i leave this?
<input type=hidden name=F_from value="nobody@bigbiz.com (Form Test - Do not reply)">F_from value="reekdog@email.com (Form Test - Do not reply)"> ??
<input type=submit value="Send">
</form>
Appreciate your help!
rangana
02-13-2008, 12:00 AM
Hi reekdog,
I've edited it according to your needs:
<form action="http://bigbiz.net/cgi-bin/forms.cgi" method="POST">
Name: <input name=reekdog>
Email address: <input name=F_to>
<input type=hidden name=msg value="thank you for signing up to our newsletter">
<input type=hidden name=yourname value="Your name is">
<input type=hidden name=F_fields value="yourname+reekdog,msg">
<input type=hidden name=F_subject value="Our Newsletter">
<input type=hidden name=F_from value="reekdog@email.com(Form Test - Do not reply)">
<input type=submit value="Send">
</form>
See if it helps :D
reekdog
02-15-2008, 04:27 AM
Hmm.. didn't work? I sent myself an e-mail but never got anything. Not unless it's extremely delayed.
Am i suppost to put something here?
<input type=hidden name=F_fields value="yourname+reekdog,msg">
Or leave as is?
Does 'yourname' mean MY name or the person filling out the forms name?
Do i type something where is says 'msg'? or leave that as is too? If i do write something what do i put??
Do i put MY name here or is this for the person filling out the form?
<input type=hidden name=yourname value="Your name is">
Is this also suppost to create an autoresponse to the person who filled out the form with "thankyou for signing up to our newsletter"? Once i filled in the form i got re-directed to a page saying "thankyou for filling out the form". Is there a way i can either:
A. Make this page one of my pages (and not the javascript webpage) with a thankyou notice? or
B. Just change the writting to something more personal towards to my site i.e "thankyou for signing up to our newsletter".
Appreciate your help. I'm just confused if 'm suppost to fill in something that says "your name" or leave it as "yourname". lol.
rangana
02-15-2008, 04:35 AM
Okay, my apologies for getting you confused :D
Anyway, Am i suppost to put something here?
<input type=hidden name=F_fields value="yourname+reekdog,msg">
This line means that the value is yourname concatenated with reekdog and the message
Yourname depends on the name of this input box:
<input type=hidden name=yourname value="Your name is"> - When you recieved this message, it states that "Your name is the name typed in the myname input box" and the message.
You can always edit msg, in this part:
<input type=hidden name=msg value="thank you for signing up to our newsletter">
Messages are delayed...YES! :D..
hope I shed some light!
reekdog
02-16-2008, 12:38 AM
Thanks! It seems i had it all filled in properly, in the morning i recieved an e-mail in my junkmail saying "thankyou for filling in the form'" or something along those lines. This was an e-mail i recieved as the person filling in the form, i never recieved anything my other account verifying someone filled in the form.
Anyway, looks like i'll be changing hosting providers as the one 'im currently with is causing me a huge amount of problems. So i might go with a hosting provider who supports .php and other functions that may come in handy later on.. when i understand html better!
Do you know who the top hosting companies are that i can check out?
rangana
02-16-2008, 12:40 AM
You're welcome reekdog! Glad I could help.
Personally, i don't know any of those top hosting companies, but you could give it a google...:D
reekdog
02-19-2008, 05:11 PM
Me again sorry!
I've just changed my hosting over to a hosting provider who accepts php. But now i'm having troubles with my php code.
In addition to wanting a code for the newsletter subscription, i'm also wanting one for basic e-mail contact. This is the code i'm currently using, i found at http://www.buildwebsite4u.com/advanced/php.shtml
I followed the instructions but when i click 'send' (the message) it comes up with the file mail.php to download??
I made no changed to the first code, which i put on my contact page. The only change i made was on the mail.php code page, where i insterted my e-mail address in the $email = $HTTP_POST_VARS['email']; field. I also changed the text in the subject and message section.
What have i done wrong??
rangana
02-19-2008, 07:05 PM
Hi reekdog,
You should note that $email=$HTTP_POST_VARS['email'] accepts the value of the email name in your form.
Whatever is the name of those input boxes in your form must be the same to the $HTTP_POST_VARS['nameofinputboxthatacceptsdata']. :D
$HTTP_POST_VARS[] was replaced by $_POST[] in version 4.0.6 or so. There is no differnce really, but HTTP_POST_VARS is now depreceated and will be dropped in future php versions.
cosas
02-19-2008, 11:55 PM
where is the part in the script that tells the form what email address to send the data to? in this case, reekdog's email address?
rangana
02-20-2008, 12:03 AM
Which are you referring??..the PHP one or the formmail script?
cosas
02-20-2008, 12:38 AM
Rangana,
I'm just trying to figure out where the heck the email address where the form should be sent to is put. I figured it should be in the php file but I don't see a place for it. the $email parameter is for the user's email who enters data into the form, right? here are the two code files
mail.html
<html>
<head><title>Mail sender</title></head>
<body>
<form action="mail.php" method="POST">
<b>Email</b><br>
<input type="text" name="email" size=40>
<p><b>Subject</b><br>
<input type="text" name="subject" size=40>
<p><b>Message</b><br>
<textarea cols=40 rows=10 name="message"></textarea>
<p><input type="submit" value=" Send ">
</form>
</body>
</html>
mail.php
<html>
<head><title>PHP Mail Sender</title></head>
<body>
<?php
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $HTTP_POST_VARS['email'];
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($subject == "") {
echo "<h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($email,$subject,$message)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email to $email</h4>";
}
?>
</body>
</html>
rangana
02-20-2008, 02:27 AM
Hi cosas,
My reply was delayed because it seemed I had difficulty entering this site..Anyway, try this code:
<html>
<head><title>PHP Mail Sender</title></head>
<body>
<?php
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($subject == "") {
echo "<h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($email,$subject,$message)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email to $email</h4>";
}
?>
</body>
</html>
See if it helps :D
reekdog
02-20-2008, 04:01 AM
I'm also confused wth where to put MY e-mail address. So when poeple sent a message, it gets directed to my e-mail. Do i put it in this code;
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $HTTP_POST_VARS[reekdog@email.com];
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
Or here;
/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", reekdog@email.com)) {
To be honest i don't feel it does goes in either of these places.. but there isn't really anywhere else in the code that hints somewhere to put my personal e-mail address for the messages to actually be sent too.
Apart from this e-mail address problem... is there anything else i would need to do to this code to make it ready to go on my site? Or is it good to go as soon as i figure out where to put my e-mail address?
Thanks again.
rangana
02-20-2008, 04:11 AM
Hi reekdog,
You should add another variable which is the header that should contain your email address, Change your PHP to:
<html>
<head><title>PHP Mail Sender</title></head>
<body>
<?php
/* All form fields are automatically passed to the PHP script through the array $_POST['']. */
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = "reekdog@gmail.com";
/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($subject == "") {
echo "<h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($email,$subject,$message,$headers)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email to $email</h4>";
}
?>
</body>
</html>
See if it helps.
reekdog
02-20-2008, 09:29 PM
Thanks, i made the change but i still have the problem i had earlier, where i will hit the submit button and get a pop-up to download the mail.php file.
Could it be something to do with the initital coding:
<form action="mail.php" method="POST">
?
Basically i have put the first code in my 'contact' page. And made another notepade page with the second code (one you just provided in your last post), and saved that as mail.php.
How would i have set this up wrong?
rangana
02-20-2008, 09:38 PM
Hi reekdog,
First, since the problem regarding the formmail script had been resolved, I suggest that you mark this thread as resolve and open another thread on Server Side Scripting regarding this problem.
A number of members could easily help you out with this...and don't forget to post a link here :D
reekdog
02-22-2008, 03:42 AM
But.. the problem isn't really resolved, cause i'm still un-able to use the code due to this download pop-up appearing when hitting submit. Although i now know where to put my personal e-mail in the script, this hasn't made it work.. so it's still usless to me.
I do appologise for dragging this thread on for ages.. but i do appreciate the help you have provided.
rangana
02-22-2008, 03:55 AM
....I see.. the formmail script did not work well.;)
I would still suggest to create another thread on the Server Side Programming section since this is a PHP problem..Other members might hesitate to chime in on this problem..and i'm not so fluent in PHP to help you out with this easily...My apologies :D
reekdog
02-24-2008, 01:27 AM
No need to appologise! I understand what you mean, i will start another thread. Thanks for the help :)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.