Skip to content Skip to sidebar Skip to footer

Html Mailto Form

Can anyone help me with my feedback form for a website I am building? I am not receiving any errors when I run this, although it doesn't actually send any email at all. The follow

Solution 1:

Sending mail from HTML Form is not a right option to do, you are using an HTTP Method (POST), so you have to set a http/https link from your action value. Otherwise, you have to send the email using the href tag, including a subject and body parameters.

E.g: <a href="mailto:admin@example.com?subject=SUBJECT&body=MESSAGE">Send Message</a>

The mail application installed in your machine would automatically opened when you click that link.(Outlook, Gmail,...) and you can choose which one you have to send the mail within it.

Solution 2:

you should maken a .php file eg.

<formmethod="post"action="mail.php">

then in your mail.php put something like this:

<?php

session_start();

$to = "contact@webmagico.be"; // this is your Email address$from = htmlspecialchars($_POST['email']); // this is the sender's Email address$naam = htmlspecialchars($_POST['naam']);
$email = htmlspecialchars($_POST['email']);

$messageText = $naam . " " . $email . " wrote:" . "\n\n" . htmlspecialchars($_POST['bericht']);

$message = array(
  "ontvanger" => $to,
  "zender" => $from,
  "naam" => $naam,
  "email" => $email
);

$valid = true;

foreach($item in $message)
{
  if(!isset($item) || $item === "")
  {
    $valid = false;
  }
}

if($valid)
{
  mail($to, $naam, $message, "From:" . $email);
}
else
{
  $_SESSION['error'] = "Forgot something!"
}

/*file that gives the response*/
header('Location: thankyou.php');


?>

You can find different alternatives about a post-form on the web. Hope this helps.

Post a Comment for "Html Mailto Form"