Solved

Sending email via Html

Posted on 2006-11-28
6
210 Views
Last Modified: 2008-03-04
I have simple html file with a form in it...I want to send email, but I want to send it automatically without the email application popping up. How can I do this with outlook ...etc popping up....How can I use the form to send email to associates automatically and then thank them for using the website..

My test html below:
<html>
<head>
<form action="mailto:somebody@such.com;test@such.com" method="post" enctype="multipart/form-data">
          <table border="0" cellspacing="2" cellpadding="0">
            <tr>

                <td><label for="namefield">Name:</label></td>
                <td><input id="namefield" type="text" name="sendername" size="55"/></td>
            </tr>
            <tr>
                <td valign="top"><label for="filefield">File to attach:</label></td>
                <td><input id="filefield" type="file" name="file" size="24"/></td>
            </tr>
            <tr>

                <td valign="top"><label for="cmtfield">Comments about file:</label></td>
                <td><textarea id="cmtfield" name="comments" rows="4" cols="40"></textarea></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" value="submit" /></td>
            </tr>
          </table>

      </form>

</head>
</html>
0
Comment
Question by:ritru
6 Comments
 
LVL 12

Expert Comment

by:enachemc
ID: 18029648
This would be security breach: you want to send an email on behalf of the user. That is prohibited by all browsers.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18029677
ritru,

You need to use some server script to do it.  In fact I would recommend that you avoid using mailto in a form for a number of reasons.  Most server languages support a mail function so you need to find out what type of server you use, what languages/technologies it supports (i.e. ASP, PHP, Perl), and what third party mail components or objects may be installed for you to use.  The script to send the message is usually very simple.

The advantage of using this type of script is it does not depend on the browser or the client's email program/service to send the message.  Mailto is not even supported in some cases by the browser or email client.  It also protects your email address.  When it is in the form, as in the example above, you expose it to bots which WILL use it for spam.  Another advantage is a server script can validate the information in the form to make sure it is correct and complete and, if it isn't, send the visitor a message to help them complete it.

If your server won't support any server script then you could look for a site that will process and send it to you but I would recommend looking at a different host before that.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 1

Accepted Solution

by:
stuartMack earned 200 total points
ID: 18029827
In PHP, this done by.....

<html>
<body><?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail( "someone@example.com", "Subject: $subject",
  $message, "From: $email" );
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='mailform.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>";
  }
?></body>
</html>
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:ritru
ID: 18029971
How could I incorporate this in form action method I have above......Is php an imbedded html product? Do I need to install php on the server?


What do I need to do for this work with the following below.

<form action="mailto:somebody@such.com;test@such.com" method="post" enctype="multipart/form-data">
         <table border="0" cellspacing="2" cellpadding="0">
          <tr>

              <td><label for="namefield">Name:</label></td>
              <td><input id="namefield" type="text" name="sendername" size="55"/></td>
          </tr>
          <tr>
              <td valign="top"><label for="filefield">File to attach:</label></td>
              <td><input id="filefield" type="file" name="file" size="24"/></td>
          </tr>
          <tr>

              <td valign="top"><label for="cmtfield">Comments about file:</label></td>
              <td><textarea id="cmtfield" name="comments" rows="4" cols="40"></textarea></td>
          </tr>
          <tr>
              <td></td>
              <td><input type="submit" value="submit" /></td>
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18030052
You would change the action attribute in the form to the name of the server page that will process the form and send the email.  StuartMack's example will work if your server supports PHP.  You need to get answers to the questions I asked first to see if PHP is an option.  Many servers will support at least one server language without any extra installation or set up.  You need to check to see what your options are.

bol
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18031919
Why the B grade for StuartMack and no points split?  If you didn't mean to close this and still have a question then let us know.

bol
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now