Solved

Sending email via Html

Posted on 2006-11-28
6
209 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:ritru
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

763 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

11 Experts available now in Live!

Get 1:1 Help Now