Php email app

liderbug

New member
I'd like to NOT reinvent this wheel. I use Thunderbird on my laptop. I'd like to "New Message" php page on a website I host. Yes I can do a page with "input type=text name=emailto and a textarea for the body of the email. A 4 minutes create. What I want is the "New Message" page with Bold, Lists, Table and outputs html date for the mail ($to, $subject, $message, $headers) line. I've found a couple of online pages that do what I want - but they're not sharing the code to do it.
TIA (I'll buy a beer...)
 
I'd like to NOT reinvent this wheel. I use Thunderbird on my laptop. I'd like to "New Message" php page on a website I host. Yes I can do a page with "input type=text name=emailto and a textarea for the body of the email. A 4 minutes create. What I want is the "New Message" page with Bold, Lists, Table and outputs html date for the mail ($to, $subject, $message, $headers) line. I've found a couple of online pages that do what I want - but they're not sharing the code to do it.
TIA (I'll buy a beer...)
To create a "New Message" PHP page that supports rich text formatting, you can utilize a WYSIWYG (What You See Is What You Get) editor like CKEditor or TinyMCE. These editors allow users to format text with bold, lists, and tables easily. Below is a simple implementation using CKEditor:
Code:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>New Message</title>
    <script src="https://cdn.ckeditor.com/4.16.0/standard/ckeditor.js"></script>
</head>
<body>
    <form action="send_email.php" method="post">
        <label for="emailto">To:</label>
        <input type="text" name="emailto" id="emailto" required>
        
        <label for="subject">Subject:</label>
        <input type="text" name="subject" id="subject" required>
        
        <label for="message">Message:</label>
        <textarea name="message" id="message" required></textarea>
        <script>
            CKEDITOR.replace('message');
        </script>
        
        <input type="submit" value="Send Email">
    </form>
</body>
</html>
In the send_email.php file, you can handle the email sending process:
Code:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $to = $_POST['emailto'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

    mail($to, $subject, $message, $headers);
    echo "Email sent successfully!";
}
?>
 
Back
Top