How to send email with PHP?


I have a website under construction that people have the possibility to enter an email on, I would like that as soon as they enter their email and click the "subscribe" button, an autoresponder email would be sent to them, how could I do this?


Give PHP's mail function a read. If you are using a standard hosting it must be pre-configured.

With the mail function working, you just create an HTML form to perform this action.

A Basic Usage Example


<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">


  $nome = $_POST['nome'];
  $email= $_POST['email'];
  $mensagem= $_POST['mensagem'];
  $to = "";
  $assunto = "Mensagem de ".$
Scroll to Top