Add Two Email address to email form

Hello, I need to add an extra email address to my email form. How would I do it. Here is the coding from the current form

<?php
$mailTo = 'test@test.com';
$name = htmlspecialchars($_POST['name']);
$lname = htmlspecialchars($_POST['surname']);
$mailFrom = htmlspecialchars($_POST['email']);
$phone = htmlspecialchars($_POST['phone']);
$subject = 'Message from your site';
$message_text = htmlspecialchars($_POST['message']);

$message =  'From: '.$name.' '.$lname.' Phone: '.$phone.'; Email: '.$mailFrom.' ; Message: '.$message_text;

mail($mailTo, $subject, $message);
?>

If you look up the mail() function in PHP, you will see for the “to” field there is multiple options. Second bullet down is what you want…

https://www.php.net/manual/en/function.mail.php

In short, just use a comma between the mail addresses… $mailto='test@test.com,test2@test.com';

I hope this is what you were looking for. :slight_smile:

[off-topic]
When you post code in the forum, you need to format it. To do so you can either select all the code and click the </> button, or type 3 backticks ``` on a separate line both before and after the code block.

I have done it for you this time.
[/off-topic]

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.