LAMP - SMTP Question.

 Is it possible to use a differnet smtp server (not local to the box) when sending mail using mail()?

 

  • Ubuntu
  • php4.4
  • apache2

 

 

Sure

the php.ini has settings for this...

[mail function] ; Setup for Windows systems
SMTP = smtp.my.isp.net
sendmail_from = me@myserver.com

even though it may be labeled for 'windows' systems, you can use it for a Linux such as Ubuntu Sitepoint has a good article on this

http://www.sitepoint.com/article/advanced-email-php

The Real Challenge is Relay Authentication

Every mail server has to protect itself from being used as a spam mail relay so you have to remember to handle this issue in your PHP coding effort. There are a couple of ways to do this depending upon how much control of the remote mail server configuration you have.

The easiest way is to just configure the mail server to allow relaying from your web server's IP address. This requires that you have configuration access to the mail server.

If you must use SMTP Authentication to relay through the remote mail server you have to have a valid user account on the mail server and you have to be able to send user/password along with the request. That'a pretty tricky scenario and it depends a lot on your target relay mail server. You have to code your own connection to the mail server (rather than just using the built-in mail function).

If you're trying to save time and you don't want to expose your web server SMTP service to the Internet there are other workarounds to secure the SMTP service on the web server so that outsiders can't use it. So many variables, so little time. I can't go into it all here.

Hope some of this helps.