Solved

Sending email via Html

Posted on 2006-11-28
6
211 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
insert text field data into html script 13 43
HTML &#0153 2 21
Outlook opens HTML email as text 4 24
key press alert 2 19
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
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…

832 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