Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Jan 07, 2010 4:43 pm 
Offline
Senior Newbie

Joined: Thu Jan 07, 2010 4:33 pm
Posts: 7
Hi,

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


Top
   
 Post subject: and one more thing...
PostPosted: Thu Jan 07, 2010 4:46 pm 
Offline
Senior Newbie

Joined: Thu Jan 07, 2010 4:33 pm
Posts: 7
Additionally, I'd like the scripts to be able to send as if the emails where coming from any address.

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.


Top
   
 Post subject:
PostPosted: Thu Jan 07, 2010 5:56 pm 
Offline
Newbie

Joined: Thu Jul 30, 2009 3:45 pm
Posts: 3
You can install postfix with:
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


Top
   
 Post subject:
PostPosted: Thu Jan 07, 2010 6:18 pm 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
You can configure Postfix as a null client.

If you need to authenticate with the mail relay, enable client SASL. On Ubuntu 8.04, Postfix is already linked with the Cyrus libraries; don't know about CentOS.


Top
   
 Post subject:
PostPosted: Thu Jan 07, 2010 6:41 pm 
Offline
Senior Newbie

Joined: Thu Jan 07, 2010 4:33 pm
Posts: 7
000 - Thank you - I did what you said and all seems to be working fine.

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


Top
   
 Post subject:
PostPosted: Thu Jan 07, 2010 6:52 pm 
Offline
Newbie

Joined: Thu Jul 30, 2009 3:45 pm
Posts: 3
I had a quick look at the link Vance posted to the Postfix manual - looks ok (some are optimizations, e.g. listening on loopback only...read the notes below it to see if you feel any line of the config would be better for your needs).

Optimization wise you shouldn't need to do anything, Postfix is very lightweight in this kind of setup.


Top
   
 Post subject:
PostPosted: Thu Jan 07, 2010 7:22 pm 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
As 000 notes, it's probably worthwhile to set "inet_interfaces = loopback-only" in /etc/postfix/main.cf. This is a bit more robust than using a firewall to block outside connections. My other references were for a slightly different type of setup than you seem to be using.

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.


Top
   
 Post subject:
PostPosted: Thu Jan 07, 2010 7:42 pm 
Offline
Senior Newbie

Joined: Thu Jan 07, 2010 4:33 pm
Posts: 7
Hi 000 & Vance,

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


Top
   
 Post subject:
PostPosted: Sat Jan 09, 2010 7:54 pm 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
You should be able to test whether mail to root works by running the following command on your Linode.

Code:
$ /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).


Top
   
 Post subject:
PostPosted: Mon Jan 11, 2010 3:22 pm 
Offline
Senior Newbie

Joined: Thu Jan 07, 2010 4:33 pm
Posts: 7
Hi Vance,

Well the scripts are working correctly, however the aliasing isnt. :(

Here is what I have:

Maillog:
The last entries are:

Code:
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


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:

Code:
root:      me@myemailaddress.com


main.cf
I changed the entries you said to say:

Code:
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


Top
   
 Post subject:
PostPosted: Mon Jan 11, 2010 10:41 pm 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
Chris Owens wrote:
Code:
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".

_________________
Rgds
Stephen
(Linux user since kernel version 0.11)


Top
   
 Post subject:
PostPosted: Tue Jan 12, 2010 6:23 pm 
Offline
Senior Newbie

Joined: Thu Jan 07, 2010 4:33 pm
Posts: 7
sweh - that worked - just did a quick test and recieved the test email to "root".

I set $myhostname to: server.twenty4.org

One last question - the to/from address of the email I received appears as - "root@server.twenty4.org" - is there a way of changing this to something more friendly (e.g. linode@twenty4.org)?

Many thanks again to all for your help.

Regards,

Chris


Top
   
 Post subject:
PostPosted: Wed Jan 13, 2010 12:31 am 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
Do you plan on doing a lot of emailing from the command line?


Top
   
 Post subject: doh!
PostPosted: Wed Jan 13, 2010 2:48 pm 
Offline
Senior Newbie

Joined: Thu Jan 07, 2010 4:33 pm
Posts: 7
Xan wrote:
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 "root@server.twenty4.org".

Thanks for your help and apologies for my ignorance on this last issue.

Best regards,

Chris


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group