How to send email

How to send emails to new users after register on my website?

In localhost, i used “sendmail” to send email from my gmail to the new user

But since i ve host my website with webhost, i don’t know how to send email.

Anyone could help me??

Could you please specify if you have a CMS that’s to say Wordpress

No I don’ t use Wordpress.

I used to send email in local with php using sendmail

You can use mail function here, it should work fine.

1 Like

how to use mail function??

mail("TO@SOMETHING.COM","SUBJECT","BODY","HEADERS (optional)");

Refer: http://php.net/manual/en/function.mail.php

$header=“MIME-Version: 1.0\r\n”;
$header.=“From:E-Denutrition “.”\n”;
$header.=“Reply-To: mail”."\r\n";
//$header .= “Bcc: perso email” . “\r\n”;
$header.=‘Content-Type:text/html; charset=“utf-8”’."\n";
$header.=‘Content-Transfer-Encoding: 8bit’;
$message=’



Confirmez votre compte !



';
mail($mail, “Confirmation d’inscription”, $message, $header);

this code function well in local.
maybe my problem is from the path?

@benz Try this sample to test :slight_smile:

<?php
  if (isset($_REQUEST['email']))  {
  //Email information
  $admin_email = "example@example.com";
  $email = $_REQUEST['email'];
  $subject = $_REQUEST['subject'];
  $comment = $_REQUEST['comment'];
  //send email
  mail($admin_email, "$subject", $comment, "From:" . $email);
  //Email response
  echo "Test Successful !!!";
  }
  //if "email" variable is not filled out, display the form
  else  {
?>
 <form method="post">
  Email: <input name="email" type="text" required/><br />
  Subject: <input name="subject" type="text" required/><br />
  Message:<br />
  <textarea name="comment" rows="15" cols="40"></textarea><br />
  <input type="submit" value="Submit" />
  </form>
<?php
  }
?>

i’ve tried it.
i got the message "Test successfull "
it seems the emails are sent. It works with hotmail, yahoo but not in yopmail