Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8410993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:19:29+00:00 2026-06-10T00:19:29+00:00

In the php.net example for mail() , two different addresses are used for $to

  • 0

In the php.net example for mail(), two different addresses are used for $to and the additional header information “To: …”:

<?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

$subject = 'Birthday Reminders for August';

// message
$message = '<html> ... </html>';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>

So my question is: you need to provide $to for the syntax of mail(), however you cannot use the format Name <email@domain.com>, this you can only do in the additional header information, right?

So first, why does the example on php.net send the mail to 4 different people (because they use different e-mail addresses for $to and for the header information), this really irritates me!?

And secondly, if I want to send the mail to only 1 person (and only 1 time) and I want to use the format Name <email@domain.com>, how should I do that? Use it in $to as well as the header information? Will the person then receive the e-mail twice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:19:31+00:00Added an answer on June 10, 2026 at 12:19 am

    Recommend you to use PHP Mailer class instead of internal mail() function. There are several reasons to use PHP Mailer:

    • the ability to use your own smtp
    • better chance to get not be listed at spam (main reason)
    • easy to use
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SOLVED! Used this example from php.net post method handling multiple uploads, with the knowledge
There is an example on php.net how to get last two domain segments in
I'm a newbie to sql and am trying to follow this example here: http://net.tutsplus.com/tutorials/php/a-better-login-system/
Going through the php.net site, it had an example for header, which says would
Let's assume my php script sends a mail to receiver@example.com using the function mail()
For example, http://www.php.net/manual/en/function.preg-replace-callback.php <?php // this text was used in 2002 // we want
I am successfully using the array_key_exists(), as described by php.net Example: <?php $search_array =
I'm using the basic example from php.net on my local machine (Macbook Pro w/
I found the following example on php.net to secure password before storing it. However,
I've pasted the example from php.net for using memcached in php and I'm getting:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.