title: How can I send email from PostgreSQL trigger?
body: <p>I using pgsql to set a trigger, when update the table dataset(change the status to Finished)
  it will automatic send a email to the email account using dataset email value and save this email in server</p>
  
  <p>but i don't know how to write in trigger function to send email, and send email in server.
  Thank you in advance</p>
  
  <p>Pg version is 9.1, and CentOS 5.8</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION sss()
  RETURNS trigger AS
  $BODY$begin
  if(NEW.publisher== 'aaaa')
  then
  //send email and save to server 192.168.171.64
  end if;
  return NEW;
  end
  
  $BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
  ALTER FUNCTION sss()
  OWNER TO postgres;
  GRANT EXECUTE ON FUNCTION sss() TO postgres;
  </code></pre>