# Ubuntu PHP mail
# Ubuntu 12.04 LTS

#  IMPORTANT : add your own data or parameters, I make use of double segments [[ your variable ]]. eg. ssh root@[[ 96.172.44.11 ]] should be replaced with ssh root@888.88.88.88 where "888.88.88.88" is your value, variable etc. I have a habit of using ":::" to indicate line ending and end of paragraph, crazy I know but be warned its just how I write ::: All notes are for my own use & should you use any it's at your own risk, it's NOT a Tutorial :::

# Resources
# https://help.ubuntu.com/12.04/serverguide/postfix.html
# http://sourcelibrary.org/2011/08/29/how-to-set-up-the-php-mail-function-on-a-ubuntu-linux-lamp-server/
# http://stackoverflow.com/questions/12083025/xampp-on-ubuntu-server-12-04-with-pear-installed-returns-errors-when-trying-to-u
# http://askubuntu.com/questions/47609/how-to-have-my-php-send-mail
# http://www.exratione.com/2012/05/a-mailserver-on-ubuntu-1204-postfix-dovecot-mysql/



# install PEAR ( Might need to run again, if error )
sudo apt-get install php-pear

# PEAR for mail()
sudo pear install mail
sudo pear install Net_SMTP
sudo pear install Auth_SASL
sudo pear install mail_mime

# install Postfix
sudo apt-get install postfix
  # Step 1: Choose Internet Site and
  # Step 2: Enter localhost at the input area of Mailserver.

# Config
sudo dpkg-reconfigure postfix

# The user interface will be displayed. On each screen, select the following values:

## Internet Site
## mail.example.com
## steve
## mail.example.com, localhost.localdomain, localhost
## No
## 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.0.0/24
## 0
## +
## all

# configure php.ini
# sendmail_path = "/usr/sbin/sendmail -t -i" ( with quotes )
sudo nano /etc/php5/apache2/php.ini

# ( OPTIONAL ) heirloom-mailx
sudo apt-get install heirloom-mailx

# ( OPTIONAL ) telnet
sudo apt-get install telnet

# To configure the mailbox format for Maildir:
sudo postconf -e 'home_mailbox = Maildir/'

# Restart postfix
sudo /etc/init.d/postfix restart

# Regenerate SSL-Cert
sudo make-ssl-cert generate-default-snakeoil --force-overwrite


###########################
# IMPORTANT !! Ensure you have a FQDN  ( Fully Qualified Domain Name )
###########################
# https://gist.github.com/yourdesigncoza/5497807/


###########################
# Mail Flagged as spam
###########################

# http://www.cyberciti.biz/tips/how-to-redirect-one-users-mail-to-another-user-with-postfix.html
# Read above and follow steps
## yourdomaine.com, mail.yourdomaine.com, wpbeta.yourdomaine.com., localhost.yourdomaine.com., localhost

# http://serverfault.com/questions/209713/change-default-from-address-from-postfix-from-www-data-to-something-else

## postmaster: yourmail@gmail.com
## monit: yourmail@gmail.com
## root: yourmail@gmail.com

http://serverfault.com/questions/209713/change-default-from-address-from-postfix-from-www-data-to-something-else
# IMPORTANT : follow steps after "Add in your main.cf ..."" At The Bottom

###########################
# Using Your Gmail address as postmaster etc. above 
###########################

# The following TXT record works for me:
v=spf1 include:_spf.google.com ~all