1

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.

Josh
  • 425
  • 1
  • 5
  • 13

3 Answers3

2

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

Jim B
  • 24,081
  • 4
  • 36
  • 60
  • @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? http://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 http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/58f05ef9-55a3-42b3-9f57-27fdc8723b8a.mspx?mfr=true – Jim B Jan 24 '11 at 05: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
  • @Jim B: Sorry I may not have been clear, but I have the emails in a db on the ubuntu server. I want to execute a php script via cron, and have that php script send the mail either directly, or via an ubuntu relay it sounds like, to the windows server's smtp queue. – Josh Jan 25 '11 at 14:15
1

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.

James Green
  • 895
  • 1
  • 9
  • 23
  • 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
0

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.

Josh
  • 425
  • 1
  • 5
  • 13