/    Sign up×
Community /Pin to ProfileBookmark

How to Include JavaScript feature in email messages

hi, the query is i have to send an html page as an to a user mail. the html page contains some input fields and a submit button with the javascript validations. the problem is i want to validate the input fields when i click the submit button and submits the page to the specified location. these actions should be done when the user opens the e-mail page.

hope u got it

to post a comment
PHP

25 Comments(s)

Copy linkTweet thisAlerts:
@amazing_andr3May 27.2005 — huh?!
Copy linkTweet thisAlerts:
@hifibeeauthorMay 27.2005 — Am i confusing?
Copy linkTweet thisAlerts:
@amazing_andr3May 27.2005 — Yeah, very. Are you trying to send HTML and Javascript in an email?

I don't think anyone runs JavaScript in email messages, for obvious security reasons. I go one step further and block HTML and images also.
Copy linkTweet thisAlerts:
@hifibeeauthorMay 27.2005 — you are right. i want to send HTML and Javascript in an email. Is there any solution to overcome this.
Copy linkTweet thisAlerts:
@Stephen_PhilbinMay 27.2005 — I'd genuinely be suprised if an email client was so stupid as to allow javascript.
Copy linkTweet thisAlerts:
@hifibeeauthorMay 27.2005 — ok, leave the javascript. how to pass the values from the html when clicking submit/
Copy linkTweet thisAlerts:
@hifibeeauthorMay 27.2005 — Can Anybody help me?
Copy linkTweet thisAlerts:
@madddidleyMay 27.2005 — too much confusing man.....


www.maddDidley.com
Copy linkTweet thisAlerts:
@crh3675May 27.2005 — $headers="Content-type:text/html";

mail("[email protected]","Subject","content",$headers);
Copy linkTweet thisAlerts:
@hifibeeauthorMay 28.2005 — thnx for your suggestion. what i need is to send an html page as an email. when i open my inbox the page should be shown in my account. when i click the submit button the values should be posted to another page. any valuable suggestions are welcome.

thnx in advance
Copy linkTweet thisAlerts:
@Stephen_PhilbinMay 28.2005 — Just use a regular form.
Copy linkTweet thisAlerts:
@hifibeeauthorMay 28.2005 — <?

$filename = "somefile.html";

$fd = fopen ($filename, "r");

$message = fread ($fd, filesize ($filename));

$to="[email protected]";

$headers = "MIME-Version: 1.0rn";

$headers .= "Content-type: text/html; charset=iso-8859-1rn";

$subject="just for test";

if(mail($to, $subject, $message,$headers))

{

echo "Mail Successfully sent";

}

else

{

echo "Error in Sending Mail";

}

fclose ($fd);

?>

this is code i have used to send the mail. The html page contains the following fileds

this is the somefile.html

<form name="frmCheck" method="get" enctype="text/plain" action="http://www.somedomain.com/somefilename.php" onSubmit="return true">

<table align="center" width="100%">

<tr><td>

<table align="center" border="1" width="40%">

<tr><Td colspan="2" align="center">Please Enter Your Details Below</Td></tr>

<tr><td align="right">Name :</td><td><input type="text" name="txt_name" size="40"></td></tr>

<tr><td align="right">E-mail Id :</td><Td><input type="text" name="txt_mail" size="40"></Td></tr>

<tr><td align="right">Phone :</td><Td><input type="text" name="txt_ph"></Td></tr>

<tr><td align="center" colspan="2"><input type="submit" name="cmd_submit" value="Go">&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="Reset"></td></tr>

</table>

</td></tr>

</table>

</form>

Can u help me a bit with this coding
Copy linkTweet thisAlerts:
@felgallMay 28.2005 — Anyone with any sense has Javascript disabled in their email program (assuming that their email program is silly enough to support Javascript in the first place). You can use regular HTML for a form in an email but all of the validation will need to be performed server side by the script that the form calls from the action attribute.
Copy linkTweet thisAlerts:
@bokehMay 28.2005 — Even if you do manage to validate your form with javascript it also must be re-validated server side. Anything else would be a major security risk.
Copy linkTweet thisAlerts:
@hifibeeauthorMay 30.2005 — pls. leave the javascript validation aside. what i want now is to send the details entered in the html page is to be sent to the page given in the action. but the values are not sent how to solve this problem. changing the method also doesnt works.

thnx all for ur valuable suggestions
Copy linkTweet thisAlerts:
@bokehMay 30.2005 — Can you say that in english please?
Copy linkTweet thisAlerts:
@hifibeeauthorMay 30.2005 — i think i'm little bit confusing. i have done the serverside validation using php. but the real problem is i cant get the values entered in the html page. i have tried both (post and get) methods. Can u get me. Oh... by gods grace it should be clear......
Copy linkTweet thisAlerts:
@bokehMay 30.2005 — Here is an example using post:
[code=php].
<?php

$self = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];

echo <<<END
<form action="$self" enctype="multipart/form-data" method="post" >
<fieldset id="fieldset">
<label for="name">Enter something and press submit </label>
<input class="form_elements" name="something" id="something" type="text" value="{$_POST['something']}">
<input id="submit" type="submit" value="Submit">
</fieldset>
END;

if (isset($_POST['something'])){
echo '<p>The form was submitted ok</p>';
}else{
echo '<p>The form was not submitted ok</p>';
}

?>
[/code]
Copy linkTweet thisAlerts:
@hifibeeauthorMay 30.2005 — Again you are wrong. the html page is sent as an attachment and the values are sent from my mail to the page specified in the action. (pls look my coding posted previously in page1)

thnx for ur reply
Copy linkTweet thisAlerts:
@bokehMay 30.2005 — Again you are wrong.[/QUOTE]
I'm not wrong at all. You asked how to send data by the post method and that is exactly what my script shows. The problem is YOU are incapable of correctly integrating that code into your html email page. If you add the following to your html email, replacing "receiving_script.php" with the url of the receiving script it will work just fine. If it doesn't it is because YOU are doing something wrong.
[code=php]
<form action="receiving_script.php" enctype="multipart/form-data" method="post">
<input class="form_elements" name="something" id="something" type="text">
<input id="submit" type="submit" value="Submit">
[/code]
Copy linkTweet thisAlerts:
@hifibeeauthorJun 01.2005 — hi, sorry for not responding soon. the html code works just fine if the page is sent to my official id. but i have tried by sending the html page to yahoo,redifmail and hotmail in all the cases the values are not submitted ( in hotmail all the attributes in the form tag are completely taken and they have put that in a hidden field). thnx for ur previous suggestion. ( furthere more dont mistake me for the word- you are wrong).

i'm awaiting for ur valuable suggestions
Copy linkTweet thisAlerts:
@bokehmanJun 01.2005 — Are you saying yahoo and hotmail reject some or all of your html email. If so either your mailserver configuration or mail() command are incorrect. Possibly it is failing an SPF test or reverse lookup.
Copy linkTweet thisAlerts:
@hifibeeauthorJun 02.2005 — Possibly it is failing an SPF test or reverse lookup.[/QUOTE]
i cant get that line . can u explain in detail. bcoz i'm poor in that area. thnx again.
Copy linkTweet thisAlerts:
@bokehmanJun 02.2005 — PTR or reverse IP:

A PTR record is what lets someone do a "reverse" DNS lookup - that is, they have your IP address and want to know what your host/domain is. At any Unix/Linux command line, you can use "dig -x" to do a reverse lookup. Not every IP address has a corresponding PTR record. In fact, if you took a random sampling of addresses your firewall blocked because they were up to no good, you'd probably find most have no PTR record - a dig -x gets you no information.

That's also apt to be true for mail spammers, or their PTR doesn't match up: if you do a dig -x on their IP you get a result, but if you look up that result you might not get the same IP you started with.

That's why PTR records have become important. Originally, PTR records were just intended as a convenience, and perhaps as a way to be neat and complete. There still are no requirements that you have a PTR record or that it be accurate, but because of the abuse of the internet by spammers, certain conventions have grown up. For example, you may not be able to send email to some sites if you don't have a valid PTR record, or if your pointer is "generic".

How do you get a PTR record? You might think that this is done by your domain registrar - after all, they point your domain to an IP address. Or you might think whoever handles your DNS would do this. But the PTR record isn't up to them, it's up to the ISP that "owns" the IP block it came from. They are the ones who need to create the PTR record. In some cases, that may be the same folks who handle your DNS, but the point is that it is not necessarily so: you may have no control over this whatsoever. See RFC 2317 and Avoid RFC 2317 style delegation of 'in-addr.arpa.' also.

[B]A mail server should identify itself using the PTR record.[/B]



SPF:

Domains use public records (DNS) to direct requests for different services (web, email, etc.) to the machines that perform those services.All domains already publish email (MX) records to tell the world what machines receive mail for the domain.

SPF works by domains publishing "reverse MX" records to tell the world what machines send mail from the domain. When receiving a message from a domain, the recipient can check those records to make sure mail is coming from where it should be coming from.

With SPF, those "reverse MX" records are easy to publish: one line in DNS is all it takes.

You also should look at the email you received and make sure the [B]header "From:"[/B] is correct.
Copy linkTweet thisAlerts:
@hifibeeauthorJun 04.2005 — hi bokehman'

this is very useful for me.( for others too). thanks for your continuous support and valuable suggestions. i also need your support in the near future too. my thanks to others too, for showing their interest in sharing their views. in the future i will try to explain my views clearly.

Again thanks
×

Success!

Help @hifibee spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...