Hi, I have a form to email working just fine, but I would like to send the form to two different emails. Any help please.
Thanks

Dani AI

Generated

This thread shows a common situation: a form that looks correct in the code but is affected by host-side mail handling. resolved it on the host side after early replies by and pointed toward script changes and recipient formatting. For future readers, a couple of practical, reliable options and checks are worth noting.

A more robust approach is to stop relying on raw outbound delivery from the web host and use authenticated SMTP or a transactional service. Maintained libraries handle multiple recipients, headers and authentication cleanly; for PHP, a popular choice is PHPMailer. Example (minimal) usage to add two recipients:

use PHPMailer\PHPMailer\PHPMailer;

require 'vendor/autoload.php';

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.example.com';
$mail->SMTPAuth = true;
$mail->Username = 'smtp-user';
$mail->Password = 'smtp-pass';
$mail->addAddress('first@example.com');
$mail->addAddress('second@example.com');
$mail->Subject = 'Form submission';
$mail->Body = 'Form data here';
$mail->send();

Quick troubleshooting checklist for host-related failures: confirm the host allows outbound mail or requires SMTP/authentication; check mail/sendmail/exim logs and PHP error_log for delivery errors; verify envelope sender and DNS records (SPF/DKIM) if messages are dropped or classified as spam; and, for simple built-in sends, confirm the mail API formatting rules (PHP’s mail() behavior is documented at PHP mail() manual). These steps clarify whether the fix belongs in the script or with the hosting provider.

Recommended Answers

All 3 Replies

Just edit your PHP script to send it to two destinations.
Normally you build up the message in steps from each field, so just add a bit for a cc as well or if you don't want to do that, repeat the entire code in the same script, but with a different destination.

the default for multiple addresses is separated by ; semicolon
try just editing the to: address address1;address2

Thanks guys, got it sorted. The problem was on the hosting server...

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.