I have a site under construction that people have the possibility to insert an email, I would like that as soon as they enter your email and click the "subscribe" button, send an automatic reply email to them, how could do that?
I have a site under construction that people have the possibility to insert an email, I would like that as soon as they enter your email and click the "subscribe" button, send an automatic reply email to them, how could do that?
Read about PHP's mail function. If you are using a default hosting it must be pre-configured.
With the function mail
working, you just need to create an HTML form to do this.
A basic example of usage
index.html
<form method="post" name="meu-form" action="send-mail.php">
Nome: <input type="text" name="nome">
Email: <input type="text" name="email">
Mensagem: <textarea name="mensagem"></textarea>
<input type="submit" value="Enviar">
</form>
send-mail.php
<?php
$nome = $_POST['nome'];
$email= $_POST['email'];
$mensagem= $_POST['mensagem'];
$to = "[email protected]";
$assunto = "Mensagem de ".$email.com
mail($to,$assunto,$mensagem);
?>
Another way to send data is as follows:
<?php
//Variáveis que recebem os dados digitados no formulário pelo id atribuído nos input
$nome = $POST[nome];
$email = $POST[email];
$assunto = $POST[assunto];
$mensagem = $POST[mensagem];
mail (
"[email protected]", //Endereço que vai receber a mensagem
"Nome: $nome
Email: $email
Assunto: $assunto
Mensagem: $mensagem", "FROM:$nome<$email>");
?>
I am not a programmer, but this is not so safe I think because in others it has the data checking to prevent the user from sending malicious data through the form. But it works normal.