i want to sen email using javascript but its not working using mailto
send email using javascript
Collapse
X
-
mailto is what you would attach to an anchor tag to alert the browser that the link is an email address and to load an email client if one is available.
It sounds like you want to give users the ability to fill in a form on your webpage and then they can send it to you, right? Well Javascript isn't the language for this. Javascript is a clientside language. You need a server side language, such as PHP, Perl, ASP, JSP etc...
The server would have to be configured to send mail. -
Instead of constructing the email yourself, you can make a button that, when clicked, opens the default email client of the user (e.g. Outlook Express, etc.). The following sample (source: JavaScriptKit.c om) puts a simple button on the screen. When clicked it opens the user's email client with the To:, Cc: and Subject already filled in.
[html]<form>
<input type="button" value="Contact Us" onclick="parent .location='mail to:you@youremai l.com?subject=T he subject you want to appear&cc=she@h eremail.com'">
</form>[/html]
When you decide that you want to make your own email form, you can see a sample of the PHP code for that at the following thread in the HTML forum http://www.thescripts.com/forum/post2268656-6.html
Ronald :cool:Comment
-
Actually i want to send the newsletter to visitor of my site who enter their email id on my site.And i have also keep email link on my site for both i have used mailto.I have done this using mailto and i get the outlook express screnn also but when i click on send at that time i got the error that method post is not allowed for that shall i have to configure the outlook express
Originally posted by ronverdonkInstead of constructing the email yourself, you can make a button that, when clicked, opens the default email client of the user (e.g. Outlook Express, etc.). The following sample (source: JavaScriptKit.c om) puts a simple button on the screen. When clicked it opens the user's email client with the To:, Cc: and Subject already filled in.
[html]<form>
<input type="button" value="Contact Us" onclick="parent .location='mail to:you@youremai l.com?subject=T he subject you want to appear&cc=she@h eremail.com'">
</form>[/html]
When you decide that you want to make your own email form, you can see a sample of the PHP code for that at the following thread in the HTML forum http://www.thescripts.com/forum/post2268656-6.html
Ronald :cool:Comment
-
Yes,
It would have to be done using server side code. Since it is easy to do in ASP.NET VB or C# I'll demonstrate how.
Assume when the visitor enters the email address it is stored in a database and you retrieve it using the appropriate driver.
VB. 2k5
Sub sendMail(emailA ddress)
Dim oSmtp As New System.Net.Mail .SmtpClient("sm tp host", port)
Dim oMessage As New System.Net.Mail Message
With oMessage.To.Add(New System.Net.Mail .MailAddress(em ailAddress)End With
.From = new System.Net.Mail .MailAddress("s ender@me.com")
.Subject = "Enter Subject"
.Body = "Enter Message Body Here"
oSmtp.Send(oMes sage)
End Sub
If you use authentication credentials for your outbound smtp before you send insert:
oSmtp.UseDefaul tCredentials = False
Dim myCreds As New System.Net.Mail .Credentials("u sername", "password")
oSmtp.Credentia ls = myCreds
You can also enable SSL.
.NET 1.1 is much different and inferior so if you do use ASP use .NET 2.0.
I don't know how to do it in classic ASP but it is also an alternative.
Try PHP too.Comment
Comment