Anvar Logo
01 / 01
Anvar Logo +91 808 999 0405

PHP Email Subscribe Form

You can simply setup the email subscribe form with php and html.
Use the below snippets for the email subscribe
HTML : Subscribe

<form action="subscribe.php" method="post">
<input name="email" id="email"type="text" required id="url"
placeholder="Enter email address ...">
<input value="Join Now" type="submit">
</form>

PHP : subscribe.php

<?php
$to = "YOUR MAIL ID";  \ Your Mail ID
$from = "no-reply@yourwebsite.com"; \ Replace it with your From Mail ID
$headers = "From: " . $from . "rn";
$subject = "New subscription";
$body = "New user subscription: " . $_POST['email'];
if( filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) )
{
if (mail($to, $subject, $body, $headers, "-f " . $from))
{
echo 'Your e-mail (' . $_POST['email'] . ') has been added to our mailing list!';
}
else
{
echo 'There was a problem with your e-mail (' . $_POST['email'] . ')';
}
}
else
{
echo 'There was a problem with your e-mail (' . $_POST['email'] . ')';
}
?>
by anvar
Published : Oct , 4

Post a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Categories