HOW TO: Sendmail and PHP

liquidg3

Registered
now this is my first how to so please bare with me:

first off...

any mail sent from the mail() function in PHP is sent from a user called "www"
now the trick is getting you@yourdomain to accept emails from www, emails from you@yourdomain.com to www work fine, but we don't care about it working like that since www is sending emails to us. Don't ask me why this is so hard, but i guess it is =) (There may be a better way, but this is very simple once you have sendmail set up.

I just got this working 10 minutes ago and on X server, so if something doen't work, just reply... ok, here we go.

First we have to create a user that sendmail can use AND likes:

STEP 1: Create a new user, whether with "Server Admin" or "System Prefrences" (Have not tried the second)

STEP 2: Make sure he/she has a home directory ie. users/tom


Next we set up our server... (This is assuming you have MX records set, if you don't, QuickDNS is a great option, or just buy a bind book)

STEP 1: Set up sendmail here, these directions can be confusing, but don't worry, we'll double check everything later.

STEP 2: Install Webmin, HOW TO courtesy yoshi . If you do not want to d/l Webmin, skip to step 4.

STEP 3: Go to yourdomain.com:10000 or however you have it set and click on servers, then scroll down to 'Send Mail Configuration'

STEP 4: Check to make sure everything is entered correctly:

Mail Aliases = I have none

Local Domains = yourdomain.com
mail.youdomain.com
localhost

Address Mapping (virtuser) = Click manual edit and enter the following

you@yourdomain.com you
www@yourdomain.com www


Outgoing Addressed (genericstable) = Click manual edit and enter
you you@yourdomain.com
www www@yourdomain.com
(same as address mapping, just reversed)

One last thing, not sure if this is required:

Spam Control (access) = click on manual edit and enter
10.0.0 RELAY <--- you reall ip minus last set of numbers
localhost RELAY

---------------------------------------------------------------------------------------------

That should do it, you may want to turn restart sendmail, turn it off then on through Webmin. . . but that should be it, any questions please post, i could very easily have missed a step. (On X server, I have mail service off, all email is now begin run through sedmail)

Enjoy :)
 
That works as well, but with webmin it is very easy to edit any settings remotely form any OS... i was at school today with Gateways, and i needed to do some re-adjusting in apache... through web admin i was able to change apache settings as well as sendmail settings through the browser, but of course its not necessary.
 
i may have misunderstood what you were trying to do, but i set up a test php page that seems to mail fine without some of the customizations you mention below.

here's a snip:

<?PHP

mail("xx@xxx.net", "Test Subject", "Test Body", "From: username@$SERVER_NAME", "-fwebmaster@$SERVER_NAME");

echo "mail sent from ";
echo $SERVER_NAME;
?>

xx@xxx.net = the address you want to send to
username = your username

does this work for you?
 
can you tell me a bit about your setup?

do you have a static IP?
is your hostname set correctly in your hostconfig file?
did you add your hostname to the hosts file?

im not saying that anything is "wrong" on your system--but you shouldnt have to tell sendmail what domain it's sending from. sendmail should be able to figure this out by itself.

ppmax
 
Back
Top