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

  • Home
  • SEARCH
  • 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 6891973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:28:37+00:00 2026-05-27T06:28:37+00:00

I have recently tried to use the php mail function to send out confirmation

  • 0

I have recently tried to use the php mail function to send out confirmation emails and I have been successful in doing so. However, when I added a few things to my script, something doesn’t seem to work.

The code below is the code that I got to work. Everything that I need for the email to contain appears.

$to        = 'Myemail';
$subject = 'Confirmation';
$message = 'This is a test';
$headers = 'MIME-Version: 1.0' . "\r\n" .
    'Content-type: text/plain; charset=iso-8859-1' . "\r\n" .
    'Content-Transfer_Encoding: 7bit' . "\r\n\r\n" .
    'From: fromemail'."\r\n" .  
    'Reply-To: replyemail' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

However, when I transfer the same headers to another script (Below), the mail delivers but there are a few issues.

1) My mail says that the mail is from nobody.
2) Instead of the headers appearing in the info area, it appears as text in the mail
From: from email
Reply-To: reply email
X-Mailer: PHP/5.2.9

The script below is being included in another program i wrote, so i am wondering if that is the problem. I don’t think its syntax because its the same headers I used above. I have attached a picture of the mail I get. https://i.stack.imgur.com/eSDyo.jpg

Your help is greatly appreciated!!!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <HEAD>
    </HEAD>
    <body>
        <?php
        $message = $_POST['message'];
        $subject = $_POST['subject'];
        if ($message != null) {
            include("connect.php");
            $extract = mysql_query("SELECT * FROM `contact` ORDER BY `id`") or die("Error");
            $counter = 0;
            while ($row = mysql_fetch_assoc($extract)) {
                $email[$counter] = $row['email'];
                $counter++;
            }
            for ($x = 0; $x < $counter; $x++) {
                $to = $email[$x];
                $subject = $subject;
                $message = $message;
                $headers = 'MIME-Version: 1.0' . "\r\n" .
                        'Content-type: text/plain; charset=iso-8859-1' . "\r\n" .
                        'Content-Transfer_Encoding: 7bit' . "\r\n\r\n" .
                        'From: fromemail' . "\r\n" .
                        'Reply-To: replyemail' . "\r\n" .
                        'X-Mailer: PHP/' . phpversion();
                mail($to, $subject, $message, $headers);
                echo "EMAIL WAS SENT TO: ";
                echo $email[$x];
                echo "<BR>";
            }
        }
        ?>
    </body>
</html>
  • 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-05-27T06:28:37+00:00Added an answer on May 27, 2026 at 6:28 am

    Your problem is with this line:

    'Content-Transfer_Encoding: 7bit' . "\r\n\r\n" .
    //---------------------------------^^^^^^^^^^^
    // Two line breaks ends the header block
    // These remaining headers are seen as part of the message body
    'From: fromemail'."\r\n" .  
    'Reply-To: replyemail' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    

    You have an extra line break here, which completes the headers portion of the message before the From and subsequent headers. Remove the extra \r\n.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been recently digging into Mobile Programming, I practically tried out the J2ME
I have recently been doing a bit of investigation into the different types of
i have recently compiled new clang(3.1 now), and tried to use it for parsing
I have recently found that Matlab can use LaTeX character sequences. However, they only
Have recently been given a project to complete which uses XML quite extensively.Am looking
Recently I have been reading about lotto wheeling and combination generating. I thought I'd
I recently tried to use backgroundworker instead of classic threads and I'm realizing that
I have recently tried to write an application in c# using EWS to read
I have recently been copying and moving a large number of files (~400,000). I
We have recently been faced with the problem of porting our C++ framework to

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.