Solved

Sending email via Html

Posted on 2006-11-28
6
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
need help with share buttons 11 106
Text color and background in a text box. 2 36
Calculating percentage 2 48
Hit counters in SharePoint 2013 2 61
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

732 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