Send E-mail in html page

How can I send emails to users from my html page? I would like to connect my html page to my mail, and then send emails with files to users. I am making something like a @noreply email. But I am a beginner, so I dont know where to start. Does anyone have suggestions?

Yes you will have to write a PHP script that assembles the email and send it to the receiver(s). You should read yourself into PHPMailer to make it more easy. If you have any difficulties we would like to help you.

I need to select the e-mail from a dropdown menu. How can I do that?

What did you try so far?

Forget about the dropdown menu haha. I will add a picture where I will show how I want it to look like at the end. I am making this because school gave me an assignment.

okay the dropdown works?

made a little example…

$data = [
        'id'  => 1,
        'name'  => 'John Doe',
        'email' => '[email protected]',
        'files' => [
        'id'  => 2,
        'name'  => 'Mae Mol',
        'email' => '[email protected]',
        'files' => [

    echo '<pre>' . print_r($_POST, true) . '</pre>';

   // send an email to $_POST['email'] ...  TODO!
    // uncomment next row if anything works fine to retrieve the page in the GET method again.
    // header('Location: email.php');

            html, body {
                background-color: #333;
            .container {
                margin: 0 auto;
                width: 1200px;
                background-color: #fff;
                overflow: auto;
            .col {
                float: left;
                box-sizing: border-box;
                width: 25%;
                height: 40px;
                text-align: center;
                padding-top: 10px;
                border: 1px solid black;
                overflow: auto;
        <div class="container">
            <?php foreach($data as $row): ?>
            <form method="post">
                <input type="hidden" name="id" value="<?php echo $row['id']; ?>">
                <input type="hidden" name="email" value="<?php echo $row['email']; ?>">
                <div class="col">
                    <?php echo $row['name']; ?>
                <div class="col">
                    <?php echo $row['email']; ?>
                <div class="col">
                    <select name="file">
                        <?php foreach($row['files'] as $file): ?>
                        <option><?php echo $file; ?></option>
                        <?php endforeach; ?>
                <div class="col">
            <?php endforeach; ?>

Thank you so much! But I only have 1 problem, in the file there is a column : Name, Adres etc… Is there any possibility that I can automatically fill those with the information of the database?

I am not sure if i understand your question? What file? How does it look like?

You select them out of the database and use them…

In which format? plain text?

Same thing. query the data that you need from the database, render a template where you insert the data between the HTML. (Maybe you would like to use a template parser like Twig or Blade)

I have literally no idea how to do that, what do I need to do for the first step?

  1. Create an HTML document that is the template for the invoice.
  2. Query the database for the data that will populate the invoice.
  3. Use a tool like wkhtmltopdf to convert the HTML document into a PDF file.
  4. Email the client with the attachment.

I have tried it with fpdf.php and it won’t work, is it because I am using a free webhost? Instead of my own computer (xampp)

What isn’t working? There are a few steps mentioned.

Oh sorry for the late reply, I have already fixed it. It was a small fault. Thanks!

Sponsor our Newsletter | Privacy Policy | Terms of Service