The Story of Postfix and the Non-Local Domain Email Host

So I have been scratching my head for a little while over how to get Postfix to deliver mail from my www.example.com site off to an external mail host, when the email address has the same domain, @example.com.

What I discovered is that I needed to do 3 things:

  1. Set my machine hostname to be distinct, ie www.example.com (vim up your /etc/hostname and then hostname -F /etc/hostname)
  2. Set mydomain and myhostname to both be the same as the machine hostname, www.example.com (this is in /etc/postfix/main.cf)
  3. Restarted postfix

The key here for me was to ensure that the hostname (and Postfixes mydomain setting) needed to be different from the actual domain of the email addresses I was trying to get mail delivered to. At that point, I didn't need to deal with local host files, or luser settings, etc. The Postfix program just sees it as an external mail address and pushes it out like any other mail. Yay!

There are a bunch of other things you should probably set as well if you are just setting up your Postfix, run /etc/postfix/post-install first-install-reminder for a fun reminder of what you need to do. http://postfix.org is also a good resource for getting things setup.

Anybody that knows a better way, please comment!

How to hide a form field and keep the value

Just a quickie. Every so often in Drupal you will come across the need to hide a form field, but can't get rid of it, because it holds a value, or you need to show it to one roll but not another, etc. In cases such as this, it is good to remember '#type' = 'value'

Thanks to Eugen Mayer for refreshing me on that.

An example would be

<?php
/**
* Implementation of hook_form_alter()
*
*/
function cool_module_form_alter(&$form, $form_state, $form_id) {
  switch (
$form_id) {
    case
'wicked_cool_form':
      if (
$form_state['pigs'] == 'fly') {
       
$form['pigs']['field_pigs_can_fly']['#type'] = 'value';
      }
    break;
  }
}
?>

Powered by Drupal, an open source content management system