How do I Set Up Postfix to work with Webhost email accounts?


I would like to set up postfix on Mandrake Limited Edition 2005.
I would like to use current email addresses that I have set up through current web hosting accounts.
(such as for the smtp and pop3, if possible)

Here is what is installed currently:
Linux localhost 2.6.11-6mdk
Apache-AdvancedExtranetServer/2.0.53 (Mandrakelinux/PREFORK-9mdk) mod_ssl/2.0.53 OpenSSL/0.9.7e DAV/2 PHP/4.3.10 mod_perl/1.999.21 Perl/v5.8.6
mySQL 4.1.11
postfix Version: 2.1.5-6mdk
phpMyAdmin Ver: 2.6.1-pl3
I don't see any reference to postfix in the phpinfo() however.
My phpinfo() shows:
Directive              ||    Local Value                        ||         Master Value
sendmail_from:         ||            ||
sendmail_path:          ||   /usr/sbin/sendmail -t -i       ||         /usr/sbin/sendmail -t -i
(it Shows sendmail, and I don't have that installed.)

Thank You Very Much for Your Help.


PS.  I've gone through some of the documentation at (or something like that,)
but I'm a little lost because I'm New to setting up the email on My Own Linux Box.
I mainly want to use this to test out My php scripts, but not be limited to just testing out the scripts.
Thanks... :)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Strictly speaking (the way I understand the question) what you are asking for isn't possible. Mail is delivered based on what the MX record (from DNS) points to. Your mail accounts on your web hosting sites have MX records pointing to their mail servers. So mail will never be delivered to this system for those addresses, regardless of how it is configured.

However, if you are only interested in sending mail from this system that's entirely possible. You will want to make sure that your PHP scripts properly send the mail so that it appears to be from a valid address within the appropriate hosted domain, but you should always do that anyway (see Example 3 at

You won't see Postfix in phpinfo() because Postfix includes a "sendmail lookalike" for compatibility reasons. PHP  will invoke /usr/sbin/sendmail to send the message and that's actually a component of Postfix.
FirstBornAuthor Commented:
Hi jlevie,

k... This is why I'm confused.

How can I get sendmail to work (to actually Mail) from My PC?

I don't have a 'FQDN' pointing to My IP address, so I'm lost on
how to get the mail() function to actually work from My PC.

I Use the proper php mail functions (according to the link that You provided above) in My php Scripts,
So, I'm back to square one here.

In the postfix file, It seems to require a FQDN in order to work properly, am I correct?

Outbound Mail:

    myorigin = $myhostname (default: send mail as "user@$myhostname")
    myorigin = $mydomain   (probably desirable: "user@$mydomain")


    mydestination = $myhostname localhost.$mydomain localhost
Relay from:
(Another Part I am not sure of)

    mynetworks_style = subnet  (default: authorize subnetworks)
    mynetworks_style = host    (safe: authorize local machine only)
    mynetworks =   (safe: authorize local machine only)
    mynetworks = (authorize local machine)
(I have to choose one.)

Then, It specifies:
Where to Relay To:

    relay_domains = $mydestination (default)
    relay_domains =           (safe: never forward mail from strangers)
    relay_domains = $mydomain (forward mail to my domain and subdomains)

Finally, It States an Explanation of Delivery Method after The following code:
(Direct or Indirect)

    relayhost =                   (default: direct delivery to Internet)
    relayhost = $mydomain         (deliver via local mailhub)
    relayhost = [mail.$mydomain]  (deliver via local mailhub)
    relayhost = [mail.isp.tld]    (deliver via provider mailhub)

The form enclosed with [] eliminates DNS MX lookups. Don't worry if you don't know what that means. Just be sure to specify the [] around the mailhub hostname that your ISP gave to you, otherwise mail may be mis-delivered.


They are not Completely Clear on the Following:
1.  What Domain Name to use, since I don't have a FQDN using My PC.
2.  How to Use a Domain Name, ESPECIALLY, Since there is NO SMTP and/or POP3 Settings to log in with, username and/or passwords, etc. (to My Webhost.)
3.  How to use the 'relayhost' if there is No login/password to actually USE the ISP's Mail Server.
(There are MORE Things that are Unclear, but These are the Main Points I'm getting at with this Question.)

What Good is Sendmail or Postfix if I can't use it on a regular Linux Box with No Way to Actually USE The Mail () Function?


The normal configuration of a Linux machine (in the absense of a real hostname) is to set the host name to be localhost.localdomain, which is an FQDN. Assuming that's the case Postfix and sendmail will be perfectly happy if you use that for the FQDN & domain.

In the general case an ISP doesn't configure their mail server to require SMTP AUTH for mail sent to or relayed via their server if it orginates from one of the ISP's "local IP's" (like you'd get on a dial-up, DSL, etc). If that's the case here you can configure Postfix to use your ISP's mail server as a relay (.relayhost = [mail.isp.tld]).
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

FirstBornAuthor Commented:
Are there any Debugging Tools for this?

I just made the changes in the postfix file and I'm STILL Not receiving any emails from testing using a php Script.
...and Yes, the php Script is doing what it's supposed (using the correct syntax, etc.)

My ISP Doesn't Require SMTP AUTH and I've got aDSL (3M/768k)

I've opened the port for My http for My IP Address and it works properly.

Will I need to configure a port in the postfix config file(s) and/or open another port for the mail to work?


FirstBornAuthor Commented:
... a port with My Router, that is...
FirstBornAuthor Commented:
Hi jlevie,

You were incorrect when You stated:
"Strictly speaking (the way I understand the question) what you are asking for isn't possible. Mail is delivered based on what the MX record (from DNS) points to. Your mail accounts on your web hosting sites have MX records pointing to their mail servers. So mail will never be delivered to this system for those addresses, regardless of how it is configured."

I have it working by using the settings of My Host (not using the www. or the mail. part of the paramaters to the hosting server.)

I used the following as debugging tools:

It was quite an inconvenience having to log in to the Konsole as root, change the config settings,
and go back and forth clicking on My php scripts 'submit' button, going back into each file (listed above as the debugging tools,) reading the error messages, looking up the errors, etc., etc., etc., but, I've got it fixed.

I'm not even using the ISP's settings.
JUST The Web Host's settings.
for the web host's settings, I use the account's IP Address, the domain name (without the www. and mail.,) and My Main Email Address.

My Only Problem Now is that I have to change where it is supposed to be:
Me <My Username @>
instead of what is Currently displayed:
system user for apache2 <>

If You can answer the Exact Setting to Change the 'From:' line to what I want,
I will close out this Q and reward You the points.


Well, I believe that what I said still stands, but I may not have explained it very well.

If I use some internet machine to send a message to one of your web hosted email accounts my mail server will lookup the MX record for the domain in the DNS. The mail server will then  send the message to the host specified in the MX for the domain regardless of how this system has been configured. However, from within this system you can send mail to any of the hosted domains because this system thinks that it is the mail server for those domains. And of course this system can send mail to any other email address, assuming it can do an MX lookup.

Does that make it more clear?

See the examples at for how to set the From (example 2) and envelope sender (Example 3) to something other than '". you really want to make it a practice of doing that anytime you send mail from PHP. Many mail servers will reject mail that looks like it comes from a web application. by setting the From and envelope sender to a valid email address they'll accept the email.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FirstBornAuthor Commented:
Hi jlevie,

Actually, That is NOT the problem.

Here is My Code that SHOULD Have generated a Different "From" Line, but Didn't because it was Over-ridden by the system:

// Build message parts
$recipient = "";
$subject = "This is the Subject.";
$message = "Here is the message.";
$headers .= "From: My Name <>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

// Send mail

This Script has worked Successfully for years for Me, so it isn't the php script that is wrong.

The Part that I needed to configure is in the Actual Postfix Config Files, but I'll find them Myself.

Thanks anyway...


PS.  I'll close out the Q, now...
I'm going to reinstall Linux anyway and get a Fresh Start.
I think that postfix is corrupt for some reason because, after working in the config files,
I get a Big Fat Red [Fail] when Stopping and Starting it, again.
Thanks... :)
Your PHP code is fine, as far as it goes. What it isn't doing is setting the envelope sender of the message and many clients will use that in a reply and mail servers will only use the envelope sender on a bounce. Unless changed by "-f username@domain.tld" in the call to sendmail the envelope sender will be the user of the process sending the mail with the hostname or domain name appended, in this case it will be apache@domain.tld. That's why I suggested you look at the examples in the PHP documentation.

You may not be aware of this, but what is in the To: & From: headers in a mail message are not used in any way for delivery of mail. They correspond exactly to information one might see on the piece of paper inside of an envelope that's delivered via surface mail. It is what is on the outside of the envelope that the postal services can see and use. A mail message has an envelope sender and recipient, that may or may not correspond to what is in the To: & From:, and it is the envelope data that the mail system uses for delivery and replies.  
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.