• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Sending email via Html

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
ritru
Asked:
ritru
1 Solution
 
enachemcCommented:
This would be security breach: you want to send an email on behalf of the user. That is prohibited by all browsers.
0
 
b0lsc0ttIT ManagerCommented:
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
 
stuartMackCommented:
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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
ritruAuthor Commented:
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
 
b0lsc0ttIT ManagerCommented:
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
 
b0lsc0ttIT ManagerCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now