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 6123619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:02:17+00:00 2026-05-23T16:02:17+00:00

I am trying to get php to send mail via the mail() command, on

  • 0

I am trying to get php to send mail via the “mail() command, on a Ubuntu linux box. The mail appears to be going and then getting dropped by send mail – and I am at a loss as to what to do about it.

The php mail() function returns true. The mail is not delivered. I have set up evolutoin to deliver vi SMTP on localhost, and sent an email to the same user – and it is delivered.

The /var/log/mail.log file contains the following entries.

Jul  9 15:15:34 anake postfix/pickup[1292]: 02879340040: uid=33 from=<www-data>
Jul  9 15:15:34 anake postfix/cleanup[2079]: 02879340040: message-id=<20110709141534.02879340040@anake>
Jul  9 15:15:34 anake postfix/qmgr[1293]: 02879340040: from=<www-data@anake.ianhobXXson.co.uk>, size=411, nrcpt=1 (queue active)
Jul  9 15:15:36 anake postfix/smtp[2082]: 02879340040: to=<hobXXson42@gmail.com>, relay=smtp.ntlworld.com[81.103.221.11]:25, delay=2.3, delays=0.1/0.02/2.1/0.13, dsn=5.0.0, status=bounced (host smtp.ntlworld.com[81.103.221.11] $
Jul  9 15:15:36 anake postfix/cleanup[2079]: 5370B340042: message-id=<20110709141536.5370B340042@anake>
Jul  9 15:15:36 anake postfix/bounce[2083]: 02879340040: sender non-delivery notification: 5370B340042
Jul  9 15:15:36 anake postfix/qmgr[1293]: 5370B340042: from=<>, size=2228, nrcpt=1 (queue active)
Jul  9 15:15:36 anake postfix/qmgr[1293]: 02879340040: removed
Jul  9 15:15:36 anake postfix/local[2084]: 5370B340042: to=<www-data@anake.ianhobXXson.co.uk>, relay=local, delay=0.03, delays=0/0.02/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Jul  9 15:15:36 anake postfix/qmgr[1293]: 5370B340042: removed

I do not understadn where it gets the “from” address from. The actual code executed is this:-

<?php 
    $to      = 'hobXXson42@gmail.com';
    $subject = 'Test email';  
    $message = 'hello - this has gone round the loop';
    $headers = 'From: ian@ianhobXXson.co.uk' . "\n" .
              'Reply-To: ian@ianhobXXson.co.uk' . "\n" .
              'X-Mailer: PHP/'. phpversion()."\r\n";
    if (mail($to, $subject, $message, $headers)) {
        echo "Message sent OK";
    } else {
        echo "message send failed";
    }

?>

Can anyone spot what is going wrong, and what I can do about it? Email addresses slightly munged in a rather obvious way.
Ian

  • 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-23T16:02:17+00:00Added an answer on May 23, 2026 at 4:02 pm

    The “from” here is the envelope sender, i.e., the address which will end up in the Return-Path header. This header cannot be changed in the same way as other headers since this is not actually part of the mail but part of the envelope. Return-Path is the address which bounces is sent to, among other things.

    You may be able to change the envelope sender by using the fifth argument of the mail() function. Postfix (which your server is running), Sendmail and Exim all makes it possible to change the envelope sender using the -f flag:

    ...
    $extra_parameters = '-fian@ianhobXXson.co.uk';
    mail($to, $subject, $message, $headers, $extra_parameters);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send an email, via php's mail function to user's every
I'm trying to send data to a url via GET in PHP. I've decided
I'm trying to send a multipart/alternative MIME e-mail via PHP script ... all works
I am trying to get this simple php mail script to send mail to
I am trying to send email using PHP mail. I get the following error:
I'm trying to get php to automatically pass the session ID via url, even
I am trying to send an email via GMail's SMTP server from a PHP
I'm trying to do a very simple mail form in PHP but get the
I am trying to create a PHP function to send an e-mail using SMTP
Having big problems trying to get my php script to send email. Using this

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.