Skip to main content
Participant
December 14, 2017
Answered

Form Problems with mailto command???

  • December 14, 2017
  • 2 replies
  • 2587 views

I have a form set up that after the user fills in the information and hits the submit button, the form will eMail that info to the admin for that site. I have checked it several ways with the same result: Mac, iPad, and iPhone users have no problem sending the info. PC users have no success at all. I have even followed tutorials step-by-step to be sure I did everything right. From what I see, I did do everything as it should have been done. Is there a "special trick" I need to use to compensate for something in Windows 10? I appreciate any suggestions or ideas. I will send what I have typed upon request if needed.

Thanks,

Rick

This topic has been closed for replies.
Correct answer Nancy OShea

I have posted a 3-part tutorial that you can reference.

Alt-Web Design & Publishing: Responsive Contact Form with Bootstrap 3.2 and PHP (Part 1)

This secure PHP script does several important things:

  • Hides your email address from robot harvesters,
  • Self-validates required input fields,
  • Tests for robot submissions,
  • Sanitizes input fields & thwarts header injections,
  • Gives feedback to users,
  • Sends form data to your email address. 

Nancy

2 replies

Jon Fritz
Community Expert
Community Expert
December 14, 2017

The mailto: command requires that there is an email client installed on the machine (like Outlook, Mac's Mail, etc). If there is no email client, say the viewer uses Gmail through their browser, hitting Send on a form that uses mailto:email@address will do nothing.

For that reason alone, it's worth never using mailto: in forms and going with a server-side form to email script (PHP for example).

B i r n o u
Legend
December 14, 2017

if your end user doesn't have to add anything manually in to the mail body manually, why don't you add a simple PHP script that will handle, in the background, the text formating throught a sendmail() function will send everything...

if you have some easy way to write PHP a phpmailer class Tutorial · PHPMailer/PHPMailer Wiki · GitHub  will be really better than a simple sendmail's function PHP: mail - Manual  ...

in any case it is really simple to be handle, compare to the mailto: protocol... if you're ok I can send you the code, but all the online tutroiel (links above) are really fully explain...

Rick_TaftAuthor
Participant
December 14, 2017

I would be very happy to look at it. Thank you.

B i r n o u
Legend
December 14, 2017

ok so the very basic script... say that you have a form containing two fields and a submit button

<form action="sendmail.php" method="post">
    <input name="name" type="text" >
    <input name="email" type="text" >
    <input type="submit">
</form>

then you will add s sendmail.php file that will contain

<?php

    $name = $_POST['name'];

    $mail = $_POST['email'];

    $subject = 'whatever subject that you need';

    $body = 'what ever text';

    $body .= "<br>";

    $body .= 'From: "'.$name.'" - '.$mail.'' . "<br>";

    $body .= $body;

    $adress="mail@domain.ext";

    $header='From: "'.$name.'"<'.$mail.'>' . "\r\n";

    $header .='Reply-To:'.$mail . "\r\n";

    $header .='Content-Type: text/html; charset="utf-8' . "\r\n";

    $header .='Content-Transfer-Encoding: 8bit' . "\r\n";

    $dest = 'pagetogo.html';

    mail($adresse,$sujet,$corps,$entete);

    // if you need uncomment the following line

   // header("Location: " . $dest );

  

?>

that is the very basic one... there is no validation, checkin/out and so on... but  if you need further detail, one can do it... either with a more sofistcated tool as php mailer