Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'd like to send mails using a PHP script that has been deployed on a CentOS machine. Problem is there is no mail server configured. There is, however, another linux machine that has a mail server configured. How can I use the "good" machine to send an email?

P.S. I have the credentials of the "good" mail server.

share|improve this question
    
Why not configure your machines email server? Also, are you sure there is no email server configured. Linux distributions generally configure email at least locally for system purposes - so services can send messages to the superuser/owner of the system etc. –  Faheem Mitha Apr 5 '11 at 10:43
    
See also: unix.stackexchange.com/questions/7044/… –  alex Apr 5 '11 at 11:28

3 Answers 3

Configure postfix on the php host to act as a relay to the "good" server.

in /etc/postfix/main.cf (on the php host)

relayhost = goodmailserver.com

and do a "postfix reload"

Also ensure goodmailserver.com is configured to accept mail from your php host

share|improve this answer

I am not sure how detailed an answer you expect, but just make an SMTP connection to the machine running the email server at port 25 or whatever port it is listening on, and send an email to it to be relayed. I don't use PHP, but I expect there is some library that will do it for you. However, using your machine's email server is better.

I think this is basically the same as this question - Send email using GMail SMTP server from PHP page.

share|improve this answer

Edit your php.ini file to set the SMTP server settings. The default settings go to localhost.

http://www.php.net/manual/en/mail.configuration.php

Edit
Err... apparently that setting is Windows only according to that document. I honestly can not wrap my head around PHP's design.

share|improve this answer
    
lol..i tried that too and then just as I saved the document, I saw the "Windows only" comment. –  Gaurav Sharma Apr 6 '11 at 7:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.