Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a server that has been sending email for the past 2 years, using PHP's mail() function. It runs Windows Server 2003. I have another server, on the same local network as it, running Ubuntu 10.10. Is there a way I could tell a PHP script executed to dump the email into the Windows' SMTP folder to go out?

UPDATE: I'll leave the above, so the other answers make sense, but just for some clarification, here is what I was trying to do. Execute a PHP script via cron on the Ubuntu server that would read a database and dump the emails into its SMTP queue via PHP's mail(), which would in turn relay the emails to a Windows server, which would actually send the emails out.

share|improve this question

3 Answers 3

You can configure the windows box to allow the mail relay from the ubunto box rather than dump files into the smtp folder

share|improve this answer
    
@Jim: Can you perhaps give me a link explaining that? I'm just a programmer, not exactly sure how to set that that up on a server. –  Josh Jan 21 '11 at 20:20
    
@Jim B: Something like this? technet.microsoft.com/en-us/library/aa998368%28EXCHG.65%29.aspx How would I then tell the Ubuntu box to dump to that server instead then? –  Josh Jan 21 '11 at 20:22
    
@josh, No take a look at microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/… –  Jim B Jan 24 '11 at 5:28
    
@Jim B: Just glancing through that, it looks like the doc describes how to configure one IIS instance to forward to another. I need to configure an Ubuntu SMTP to relay to an IIS. Is that possible? –  Josh Jan 24 '11 at 16:37
    
@so you question is morphing from how to get mail from PHP to how to get mail from ubunto to windows. I'm sure it's possible to relay mail from 2 different servers but I'm not sure that's the approach I would take. That aside, setting the relay resctictions are the same regardless of source system in IIS, there is nothing specifically requiring windows in order to allow relay. –  Jim B Jan 24 '11 at 21:47

Looking down http://php.net/manual/en/function.mail.php (under "Notes") you can make the mail() function talk directly to a Mail Transfer Agent running on a remote host (although bizarrely this functionality appears to be unique to the Windows implementation, based on the documentation, so if you ever need to move the script to another platform you'll need to bear this in mind...)

Try this, in php.ini on the Windows host:

[mail function]
SMTP = yourubuntumachine.domain.com; for Win32 only
smtp_port = 25

You'll need some kind of MTA running on the Ubuntu host, of course, but it's simple enough to install (say) Exim (in the exim4-daemon-light package) and configure it to relay mail only from your Windows box.

share|improve this answer
    
I need to send from an Ubuntu box, but mail from a Windows box, so I don't think this will work then, will it? –  Josh Jan 24 '11 at 16:37
    
Sorry, I thought the PHP was running on Windows and the mail server on Linux -- is this the opposite way round? –  James Green Jan 25 '11 at 10:41
    
Yes, there is a db of emails on the linux box, that will be hit by a cron'd php script, which needs to send the emails to the window's smtp, either directly, if possible, or apparently via a relay in the ubuntu smtp server. –  Josh Jan 25 '11 at 14:16
    
Ah - apologies, I have answered the exact opposite of the question then, sorry! –  James Green Jan 26 '11 at 19:00
up vote 0 down vote accepted

Here is what I did to solve this, since I wasn't clear, and the other answers were backwards (my fault).

I setup ssmtp on the Ubuntu box as per this guide: http://www.davidhurst.co.uk/2007/06/19/php-mail-and-ssmtp-on-debian-linux/ . It involved editing the ssmtp.conf file, and editing php.ini to use a different sendmail_path.

I then configured MailEnable, the SMTP server running on Windows to allow incoming relay connections.

I restarted Apache, and now when I PHP mail() from the Ubuntu box, they get relayed to the Windows SMTP server and sent out.

share|improve this answer

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.