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.

In my Mac, this is what I followed:

  1. Following is the ruby file I'm testing with. This is capable of reading from STDIN and write in a file sample.mail:

    #!/usr/bin/env ruby

    while line = STDIN.gets
    f = File.open("/Users/username/sample.mail", "a+")
    f.puts line
    f.close
    end

  2. Edited /etc/aliases and added this line:

username: "|/Users/username/stdinpipe.rb"

  1. Edited /etc/postfix/main.cf and added this line

allow_mail_to_commands = alias,forward,include

  1. Used sudo newaliases to sore the changes.

Now, at this stage I am expecting when I send a mail to username@localhost it should be appended to /Users/username/sample.mail.

But it's not happening.

Where did I do wrong?

share|improve this question
    
What is in postfix logs? –  AlexD Jun 27 '11 at 12:06

2 Answers 2

up vote 2 down vote accepted

By default, postfix in OS X does not have any alias_maps specified. You need to make sure that this line is not commented out in main.cf:

alias_maps = hash:/etc/aliases

Also, the script must be executable by the _postfix user. The file you want to write to must be owned and writable by the _postfix user

After those are corrected you need to reload postfix: sudo postfix reload

share|improve this answer
    
Great, thanksalot :) I had to restart the postfix daemon with sudo launchctl stop org.postfix.master followed by sudo launchctl start org.postfix.master –  intellidiot Jun 28 '11 at 7:06

You probably need to ensure that the script is made executable. IE, run chmod a+x on the script. Also, your alias example line has a capital "/Users", which is non-conventional and unix respects case in paths and files (unlike windows), so make sure the case matches.

If that fails, you might replace the "#!/usr/bin/env ruby" with "#!/usr/bin/ruby" (or wherever your ruby is located).

share|improve this answer
    
On a Mac, the /Users folder is in fact with a capital U. However, by default the filesystem on a Mac is not case sensitive. –  Frands Hansen Jun 27 '11 at 15:06

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.