HI,
If anyone could help me it would be great! So I am building a website for some snowboarders and they would like to collect Emails for their newsletter. this is the code i have put in. I know it is simple but when People submit there emails I want it to be send automatically to my buddies email, with out opening a email program.
Thanks,

<form action="mailto:drewkornet@gmail.com" method="post" name="newsletter" class="newsletter" id="Newsletter">
      <label>Name
      <input name="Name" type="text" id="Name" maxlength="20" />
      </label>
      <br />
      <label>E-mail
      <input type="text" name="E-mail" id="E-mail" />
      </label>
      <br />
      <label>
      <label>Click Submit and Send
      <input type="submit" name="button" id="button" value="Submit" />
      </label>
      <div align="center"></div>
      </label>
    </form>

Dani AI

Generated

used a client-side mailto: form, which will open the user’s email program instead of sending silently. is correct that a server-side solution is required. ’s script is one option, but a modern, reliable approach is: (1) post the form to a server script, (2) validate and store the address, (3) send mail from the server (preferably via authenticated SMTP or an API), and (4) use double opt-in to confirm subscriptions.

A minimal HTML form that posts to a PHP handler:

<form method="post" action="/subscribe.php">
  <input name="name" type="text" maxlength="50" />
  <input name="email" type="email" />
  <button type="submit">Subscribe</button>
</form>

Server-side example (use composer + PHPMailer for SMTP delivery):

<?php
require 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;

$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) exit('Invalid email');

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.example.com';
$mail->SMTPAuth = true;
$mail->Username = 'smtp-user';
$mail->Password = 'smtp-pass';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

$mail->setFrom('no-reply@example.com','Newsletter');
$mail->addAddress('admin@example.com');
$mail->Subject = 'New signup';
$mail->Body = "Name: $name\nEmail: $email";
$mail->send();

Notes, security and troubleshooting: always validate with filter_var (see PHP docs), strip CR/LF to prevent header injection, use prepared statements when saving to a database, enable SMTP debug if mail fails, and use double opt-in and an unsubscribe mechanism to comply with CAN-SPAM rules. For SMTP libraries and current best practices, see PHPMailer and the PHP filter_var reference (https://www.php.net/manual/en/function.filter-var.php). For legal basics on bulk email rules, consult the FTC CAN-SPAM guide (https://www.ftc.gov/business-guidance/resources/can-spam-act-compliance-guide-business).

Recommended Answers

All 2 Replies

Yeah... mailto doesn't work that way. Take a quick search on google or Daniweb(there are plenty of them) on email scripts.

If I may offer a suggestion. I use a email script on my site that I would highly recommend. It is capable of a wide range of functions.
You can find it at

Again, This is my suggestion, there is others out there.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.