Help installing Postfix on CentOS - Null Client
I'm using Google Apps to host my "proper" email for my users, however I need to enable sending of email on a couple of sites I have hosted on my Linode (CentOS 64Bit).
I'd like to have it so that as I add more and more sites (and as my Linode grows) that all sites can take advantage of sending emails via PHP etc. I have zero requirements for my server to receive emails, I just need to send them via any scripts (99% of them PHP based) on the server and have no external clients be able to take advantage of Postfix (localhost only).
From looking around I believe Postfix (as a null client) is the best way to go.
However I am having trouble finding a good tutorial or advice on how I would achieve this, as most tutorials go all out to help me install a fully configured IMAP/POP3/WEBMAIL email hosting solution - not what I need.
I would massively appreciate any assistance that anyone could offer.
Many thanks,
Chris
13 Replies
So that if I have a contact form, and that form is filled in - then the person enquiring effectively becomes the "from" address and when I and others receive the email we can simply hit reply.
yum install postfix
Then you need to take make a few minor config changes in /etc/postfix/main.cf
Change the following parameters:
myhostname - set to your server's hostname
mydomain - set to your domain name
I think you can get away with just that for outbound only. If you block incoming traffic to port 25 you don't need to worry about open relay issues (and postfix is pretty secure out of the box anyway).
Then start it up with: service postfix start
That should be all you need… if you want to wrap scripts around the mail command and it's not there try running yum install mailx (can't remember if it will be there already off the top of my head).
Hope this helps
null client
If you need to authenticate with the mail relay, enable client SASL
Vance - As I'd already followed 000's instructions and it seems to be working as intended - is there anything that I should look at from the links you provided?
Finally, having just followed 000's instructions (only edited the 2 entries) is there anything else I need to/can disable to optimise the memory/cpu usage of postfix?
Thank you both again - linode and it's community is amazing.
Regards,
Chris
Optimization wise you shouldn't need to do anything, Postfix is very lightweight in this kind of setup.
Also note that many programs will send error reports to root. If you don't plan to read mail locally on your Linode, you'll probably want to edit /etc/aliases to direct mail for root to your real e-mail address. Don't forget to run newaliases after making your edits.
You'll want to be careful about letting people send arbitrary messages via a web page where they get to pick the "To:" address - this can easily cause you to become a spam source.
I've made the loopback change and suggested - is there anyway to check if the alias modification and newaliases worked or do I need to wait till something tries?
Thank you both again for you advice.
Regards,
Chris
$ /usr/sbin/sendmail -t
To: root
Subject: Test
testing 123
.
If it works, you'll get a message at the address you set the alias to with the subject "Test" and the body "testing 123". You can also look in your mail logs to see that the message was delivered (or delivery was attempted).
Well the scripts are working correctly, however the aliasing isnt.
Here is what I have:
Maillog:
The last entries are:
Jan 11 18:46:04 li140-172 postfix/pickup[31811]: 5302D3B231: uid=0 from= <root>Jan 11 18:46:04 li140-172 postfix/cleanup[31824]: 5302D3B231: message-id=<20100111184604.5302D3B231@babygirl>
Jan 11 18:46:04 li140-172 postfix/qmgr[31812]: 5302D3B231: from=<root@babygirl.twenty4.org>, size=299, nrcpt=1 (queue active)
Jan 11 18:46:04 li140-172 postfix/smtp[31826]: 5302D3B231: to=<root@babygirl.twenty4.org>, orig_to=<root>, relay=none, delay=20, delays=20/0.01/0/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=babygirl.twenty4.org type=A: Host not found)
Jan 11 18:46:04 li140-172 postfix/cleanup[31824]: 5A4D33B232: message-id=<20100111184604.5A4D33B232@babygirl>
Jan 11 18:46:04 li140-172 postfix/bounce[31827]: 5302D3B231: sender non-delivery notification: 5A4D33B232
Jan 11 18:46:04 li140-172 postfix/qmgr[31812]: 5A4D33B232: from=<>, size=2176, nrcpt=1 (queue active)
Jan 11 18:46:04 li140-172 postfix/qmgr[31812]: 5302D3B231: removed
Jan 11 18:46:04 li140-172 postfix/smtp[31826]: 5A4D33B232: to=<root@babygirl.twenty4.org>, relay=none, delay=0, delays=0/0/0/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=babygirl.twenty4.org type=A: Host not found)
Jan 11 18:46:04 li140-172 postfix/qmgr[31812]: 5A4D33B232: removed</root@babygirl.twenty4.org></root></root@babygirl.twenty4.org></root@babygirl.twenty4.org></root>
Looking at the above - I notice that it says there is no A record for babygirl.twenty4.org - which is correct, I haven't setup an A record for "babygirl" - do I need to?
aliases
I left everything else the same and modified the last time to read:
root: me@myemailaddress.com
main.cf
I changed the entries you said to say:
myhostname = babygirl
mydomain = twenty4.org
I entered babygirl for myhostname (as thats what I have in in my /etc/hostname - which I did after following this tutorial
And twenty4.org is one of the sites I'm running on my linode.
I ran newaliases after making the change and have also reloaded postfix.
Have I done anything incorrectly?
Any advice is appreciated.
Thanks,
Chris
@Chris Owens:
myhostname = babygirl
I think that should the full domain name, not the local name.
What's the output of "postconf"? On my machine it shows the fully qualified domain name (FQDN) for "myhostname".
I set $myhostname to: server.twenty4.org
One last question - the to/from address of the email I received appears as - "
Many thanks again to all for your help.
Regards,
Chris
@Xan:
Do you plan on doing a lot of emailing from the command line? I see what you mean…
I just checked mailing through a PHP script and it honours the from address and doesn't use "
Thanks for your help and apologies for my ignorance on this last issue.
Best regards,
Chris