views:

151

answers:

6

I wish to send an email from my localhost machine (using PHPs mail function) but I can not do this since I don't have a mail server. In addition, I need to be able to send emails through a network that is heavily firewalled (to what extent I do not know yet).

My idea is to make use of "QK SMTP Server 3" and get that to use an external server I have as a "Relay server". Will this work? Is there an easier option?

If my approach is Ok. I would like to know how I can open port 25 on my server so it can receive this request. By executing this command I get:

[root@balder296 ~]# service iptables status
Firewall is stopped.
[root@balder296 ~]#

Thank you for any help and advice.

Solved

Hotmail (surprisingly) provides a free relay service. I hope this works for me when I test this! But an external mail server is the way to go.

+1  A: 

Maybe there is a (good?) reason which explain why the network where you are is heavily firewalled.

Why don't you ask guy's from the network what is the good solution to send mail ?

A: 

If you have a Google Mail account, you can use it to send emails using Swift Mailer.

shadowhand
A: 

You'll need a machine behind the firewall running a mailserver. Preferably this should be all it should be used for. While everything else behind it should be blocked from opening outgoing connections on port 25, this one should. Have the mailserver on the machine running your application relay through that machine. I work for a hosting company, and that's what we do with our shared hosting servers. This way, you can track any outgoing mail to ensure that nothing behind the firewall doing anything underhand.

You're friendly neighbourhood sysadmin will almost definitely set this up if you ask nicely.

Keith Gaughan
+2  A: 

Figure out if you can connect to the Internet on port 25 (SMTP)

  • telnet gmail-smtp-in.l.google.com 25 (this is one of the Gmail servers)

If you're able to open up a connection, you can simply install a mail-server and use the mail() function to send messages.

  • yum install postfix (for example, from your 'service' remark I assume you're running Redhat or Centos)

If you're unable to connect to Internet mail servers on port 25, you can try finding an internal mail relay (this is something you will have to find yourself, depending on your network).

At that point you have two options. You can use the internal mail() function with your local mail server if you define the 'relay' parameter in your mails-server (/etc/postfix if you're using Postfix).

The other option is to follow this guide and get get PHP to send the messages to an internal relay.

Andrioid
A: 

If this is going to be for a public application, keep in mind that even if you can get SMTP access outbound you are likely to run into problems down the road. Anti-SPAM protections have gotten fairly picky about network behavior. For example is there is a valid SMTP server on the network and you setup another that may cause trouble for both servers if they appear to have the same IP address from outside the network. A couple of the major blacklists automatically block addresses that appear to have more than one server on them.

If you are trying to get around a network admin, at best you are likely to have a fragile system in place. Depending on your network's rules/setup you MIGHT be able to setup your SMTP server package to relay messages off another email server on the network. This should require working with the network or email admin.

acrosman
A: 

I've used SwiftMailer in the past and then setup a generic gmail account to send the mail through. The one thing I found out is that it's best to keep the from address as the gmail account you setup otherwise spam filters tend to trash the email.

Jason