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 set up an ubuntu webserver, and need to be able to send email from forms via php. The server hosts multiple websites, and this issue persists for all of them.

When I have a form send to a domain name not hosted on the server (ie gmail, yahoo, etc) the email sends from the form without a problem.

When I have the form send to a user@domain.com that is hosted on the local server I receive a "user unknown" error. This is because I have not created the accounts on the server, but I do not plan to... the email is hosted elsewhere [gmail].

This is an example of what I am seeing in /var/mail/www-root...

The original message was received at Sun, 17 Oct 2010 18:39:41 -0700 from www-data@localhost

----- The following addresses had permanent fatal errors ----- 
orders@domain.com
(reason: 550 5.1.1 <orders@domain.com>... User unknown)
(expanded from: orders@domain.com)

What is the proper way to set this up?

Thank you.

share|improve this question
add comment

3 Answers

In your sendmail.mc add:

define(LUSER_RELAY,`mail.google.com')dnl

Or whatever is the SMTP outgoing server that Google has told you to use. Depending on your linux distribution produce sendmail.cf and restart sendmail (in Debian this is done by running sendmailconfig).

EDIT: If the machine is not to accept any incoming email, it may be better to install nullmailer:

# apt-get install nullmailer
# dpkg-reconfigure nullmailer

EDIT: Since nullmailer cannot work with Gmail you can use ssmtp

share|improve this answer
add comment

If you don't care about which MTA you actually use, I recommend installing Postfix. It's fairly easy to configure and I use it on all of my web servers as well as the mail servers I maintain for clients.

sudo apt-get install postfix

If Postfix is already installed then instead run sudo dpkg-reconfigure postfix

Follow the menus, choose "Satellite system," stick to the defaults until you are asked for the SMTP Relay Host where you will enter a SMTP host you're allowed to use.

You may also have to put the following in /etc/postfix/main.cf

# Disable local delivery
mydestination =
local_recipient_maps =
local_transport = error:local mail delivery is disabled
share|improve this answer
    
I am not sure what SMTP host to use - I know Gmail is free, but we have to configure SSL and a bunch of other things to use? –  naunu Oct 28 '10 at 22:26
add comment

While getting to postfix may be a good idea, but this kind of problem could also mean you are sending email from a blacklisted IP. Many DHCP assigned ISP IPs are in blacklist of http://www.spamhaus.org/.

If you send email from sendmail it won't show the exact error and keep ranting annoying User Unknown error unless you enable some logging. However, with postfix is automatically tells you the exact problem such as

From any mail server

Mail server said: 550 Blacklisted in zen.spamhaus.org: http://www.spamhaus.org/query/bl?

From Google

status=bounced (host gmail-smtp-in.l.google.com[74.125.142.27] said: 550-5.7.1 [IP] The IP you're using to send mail is not authorized to 550-5.7.1 send email directly to our servers. Please use the SMTP relay at your 550-5.7.1 service provider instead. Learn more at 550 5.7.1 http://support.google.com/mail/bin/answer.py?a

From Hotmail

status=bounced (host mx4.hotmail.com[65.55.37.120] said: 550 DY-001 (COL0-MC4-F9) Unfortunately, messages from <IP> weren't sent. Please contact your Internet service provider. You can tell them that Hotmail does not relay dynamically-assigned IP ranges. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors.

If you are using your own custom Mail server, you could perhaps fix it otherwise you need to get ISP to resolve this issue.

HTH

share|improve this answer
add comment

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.