Yesterday I needed to send an email from a php page to an email address, sounded simple enough but when I tried it it did not work, so after a bit of searching I found lots of people having the same issues but no simple instructions to get it working.
Here are the simple instructions.
My Setup:
Ubuntu Server default install with lamp.
Exchange server installed on a different server.
The steps taken:
1) Install sendmail
    from the terminal
    sudo apt-get install sendmail
2) Edit php.ini
    from the terminal
    sudo vim /etc/php5/apache2/php.ini
    approx line 1059 change
    ;sendmail_path =
    to
    sendmail_path = /usr/sbin/sendmail -t -i 
    write changes and exit
3) restart apache2
    from the terminal
    sudo /etc/init.d/apache2 restart
4) edit hosts file
    from the terminal
    sudo vim /etc/hosts
    near the top add
    127.0.0.1 hostname.local hostname
    where hostname = your hostname
5) Create your php test page
     from termianl
     sudo vim /var/www/mail.php
     add code
Write changes and exit
6) From a machine with a web browser access the mail.php.
ALL DONE
    
 
No comments:
Post a Comment