0% found this document useful (0 votes)
19 views2 pages

Email Subscription PHP HTML

This document provides instructions for creating a basic email subscription form using HTML and PHP, which sends a confirmation email to the user upon submission. It includes the necessary HTML form code and a PHP script for processing the email input and sending the confirmation message. Additional notes highlight the need for proper email configuration on the server and the lack of database storage for the emails collected.

Uploaded by

rajesh2002paul2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Email Subscription PHP HTML

This document provides instructions for creating a basic email subscription form using HTML and PHP, which sends a confirmation email to the user upon submission. It includes the necessary HTML form code and a PHP script for processing the email input and sending the confirmation message. Additional notes highlight the need for proper email configuration on the server and the lack of database storage for the emails collected.

Uploaded by

rajesh2002paul2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Email Subscription with PHP and HTML

Introduction

This PDF shows how to create a basic email subscription form using HTML and PHP. When a visitor submits

their email, a confirmation message is sent to their inbox.

Technologies Used:

- HTML for the form

- PHP for backend processing and sending email

Make sure to replace 'yourname@yourdomain.com' with your real email address. Also, ensure that your

server supports PHP mail functions or configure SMTP on localhost.

HTML Form Code

<form action="subscribe.php" method="post">

<input type="email" name="email" placeholder="Enter your email" required>

<button type="submit" name="submit">Subscribe</button>

</form>

PHP Script (subscribe.php)

<?php

if (isset($_POST['submit'])) {

$email = $_POST['email'];

$to = $email;

$subject = "Subscription Confirmation";

$message = "Thank you for subscribing! You'll now receive updates from us.";

$headers = "From: yourname@yourdomain.com\r\n";

$headers .= "Reply-To: yourname@yourdomain.com\r\n";

$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";


Email Subscription with PHP and HTML

if (filter_var($email, FILTER_VALIDATE_EMAIL)) {

if (mail($to, $subject, $message, $headers)) {

echo " Subscription email sent to $email";

} else {

echo " Failed to send email. Try again later.";

} else {

echo " Invalid email format.";

?>

Notes

- This script uses PHP's built-in mail() function.

- It does not store emails in a database.

- To use on localhost (XAMPP/WAMP), configure sendmail or use PHPMailer.

- For production, make sure your hosting server allows email sending.

You might also like