Tag Archives: sendmail

fake procmail script

This is similar to fake sendmail. Need a procmail script to deliver messages locally on your machine? Need to do postfix development local for mail ? This will override the “to” field on postfix (more or less) by saving all mail to a local file. Here is a PHP script you can use: Tweak it to fit your needs, adjust #!/usr/bin/php to point to the php file that you use on your system if necessary ( try which php ) The script may need to be in a folder that it has write access to, or that postfix / procmail has write access to. After saving the script to something like /usr/local/fake-procmail.sh edit /etc/postfix/main.cf and add or edit this line: mailbox_command = /usr/local/fake-procmail.sh Also make sure you make the script executable: chmod +x /usr/local/fake-procmail.sh You will also need to route all mail to the localhost by adding these lines: luser_relay = [email protected] local_recipient_maps = mydestination = pcre:/etc/postfix/mydestinations Change johndoe to your user name. Also create a file /etc/postfix/mydestinations and add this to it: /.*/ ACCEPT More info about that here. Then restart postfix if needed: sudo /usr/sbin/postfix stop sudo /usr/sbin/postfix start And try sending a message, or piping some text to the script: echo hello there | mail -s “test message” [email protected] Or echo hello there | /usr/local/fake-procmail.sh There should now be messages in /tmp/procmail-messages/ – change the script to change the location where they are saved. It’s easier than setting up and chrooting postfix on Mac OS X Lion … Continue reading

Posted in Tech Tips, Web Development | Tagged , , | Leave a comment

Fake Sendmail for Mac (linux)

When developing in PHP perhaps you need to set up a sendmail that just outputs things to text. No need to setup delivery via SMTP. Just create an executable ruby script somewhere, for example: /usr/bin/fake-sendmail.sh with following content: $ touch /usr/bin/fake-sendmail.sh # make it executable (will require root priv.) $ chmod +x /usr/bin/fake-sendmail.sh #!/usr/bin/ruby path = “/tmp/fake-mailer” Dir.mkdir(path) if !File.exists?(path) File.open(“#{path}/#{Time.now.to_i}.txt”, “w”) do |f| f.puts ARGV.inspect $stdin.each_line { |line| f.puts line } end Then edit php.ini sendmail_path = /usr/bin/fake-sendmail.sh props to dan for the script Update I changed one line to use a micro-time format because I was having some trouble with a very fast sending script overwriting some of the existing e-mail files. So, here is the new line to insert: File.open(“#{path}/#{(Time.now.to_f.to_s.gsub(“.”,””)+’00000000′)[0..14]}.eml”, “w”) do |f| Do you need fake sendmail for windows? Check out Byron’s fake sendmail for windows.

Posted in Tech Tips, Web Development | Tagged , , , , | 1 Comment