Automated mailing system html using gmail github
Here's a step-by-step guide to creating an automated mailing system using HTML, Gmail, and GitHub:
Step 1: Create a GitHub Repository
- Go to GitHub and create a new repository for your project.
- Name your repository (e.g., "Automated Mailing System").
- Initialize a new Git repository by running
git init
in your terminal.
Step 2: Create an HTML Form
- Create a new file called
index.html
in your repository and add the following HTML code:<!DOCTYPE html> <html> <head> <title>Automated Mailing System</title> </head> <body> <h1>Automated Mailing System</h1> <form action="mailto:[email protected]" method="post" enctype="text/plain"> <label for="name">Name:</label> <input type="text" id="name" name="name"><br><br> <label for="email">Email:</label> <input type="email" id="email" name="email"><br><br> <label for="message">Message:</label> <textarea id="message" name="message"></textarea><br><br> <input type="submit" value="Send"> </form> </body> </html>
Replace
[email protected]
with your Gmail address.
Step 3: Create a PHP Script
- Create a new file called
sendmail.php
in your repository and add the following PHP code:<?php // Configuration $to = '[email protected]'; // Replace with recipient's email $subject = 'Automated Mailing System';
// Get form data $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message'];
// Send email using Gmail SMTP $smtp = 'smtp.gmail.com'; $port = 587; $username = '[email protected]'; $password = 'your-password';
// Create a new PHPMailer object $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = $smtp; $mail->Port = $port; $mail->SMTPAuth = true; $mail->Username = $username; $mail->Password = $password;
// Set email parameters $mail->setFrom($email, $name); $mail->addAddress($to, 'Recipient Name'); $mail->Subject = $subject; $mail->Body = $message;
// Send email if (!$mail->send()) { echo 'Error sending email: '. $mail->ErrorInfo; } else { echo 'Email sent successfully!'; } ?>
Replace `[email protected]` with the recipient's email, and `[email protected]` and `your-password` with your Gmail address and password.
**Step 4: Configure GitHub Pages**
* Go to your GitHub repository settings and click on "GitHub Pages".
* Select the branch you want to use for your GitHub Pages (e.g., "main").
* Set the "Source" to your `index.html` file.
* Click "Save" to save your changes.
**Step 5: Deploy Your Project**
* Go to your GitHub repository and click on the "Code" button.
* Click on the "Download ZIP" button to download your repository as a ZIP file.
* Extract the ZIP file to a directory on your local machine.
* Open the `index.html` file in a web browser to test your automated mailing system.
**Step 6: Set Up Gmail SMTP**
* Go to your Gmail account settings and click on "Forwarding and POP/IMAP".
* Enable "Less secure app access" to allow your PHP script to access your Gmail account.
* Note: This is not recommended for production use, as it may compromise your account security.
**Step 7: Test Your Automated Mailing System**
* Fill out the HTML form with your name, email, and message.
* Click the "Send" button to send the email.
* Check your recipient's email to see if the email was sent successfully.
That's it! You now have an automated mailing system using HTML, Gmail, and GitHub.