Linux serverNETWORK ADMINISTRATIONSsmtp server liux

Ubuntu: How to have my PHP Send mail?

Ubuntu: How to have my PHP Send mail?

Question: I installed Ubuntu 11.04, LAMP using tasksel.
I find that PHP mail() does not work.
I suppose I need to enable it or something? How do I do that?

Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful):

== This solution helped 1 person ==
https://askubuntu.com/a/47618/527764, con-f-use.
I have one thing to add about the “dummy gmail account”:
This is highly recommended because you have to configure your gmail account to
allow less secure applications: https://www.google.com/settings/u/0/security/
lesssecureapps Otherwise you will get a “please log in using your web browser
and then try again” error in your /var/log/mail.log file.
also I found that I get a timeout error unless I send the gmail smtp sever my
root certificate. To do this:
sudo nano /etc/postfix/main.cf
add the following to the bottom of the file
smtp_tls_CAfile = /etc/postfix/cacert.pem
Then copy the thawte root cert to the cacert.pem file:
cat /etc/ssl/certs/thawte_Primary_Root_CA.pem | sudo tee -a /etc/postfix/
cacert.pem
Here is the link I used : https://easyengine.io/tutorials/linux/ubuntu-postfix-
gmail-smtp/
Hopefully this saves someone a few hair follicles…

== This solution helped 29 people ==
PHP requires an SMTP client to send mail. You could install a full-featured
mail transfer agent (MTA) like https://secure.wikimedia.org/wikipedia/en/wiki/
Postfix_%28software%29 to serve this function, but it’s overkill if you only
need to send mail through PHP. Instead, install msmtp. It’s lightweight and
much simpler to configure.
Install msmtp
sudo apt-get install msmtp-mta ca-certificates
Configure it
Create a new configuration file:
sudo vi /etc/msmtprc
…with the following configuration information:
# Set defaults.
defaults

# Enable or disable TLS/SSL encryption.
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

# Set up a default account’s settings.
account default
host <smtp.example.net>
port 587
auth on
user <username@example.net>
password <password>
from <address-to-receive-bounces@example.net>
syslog LOG_MAIL
You need to replace the configuration data represented by everything within “<”
and “>” (inclusive, remove these). For host/username/password, use your normal
credentials for sending mail through your mail provider.
Tell PHP to use it
sudo vi /etc/php5/apache2/php.ini
Add this single line:
sendmail_path = /usr/bin/msmtp -t

== This solution helped 2 people ==
This is an old question and there are worthy answers above, but I needed exim
for my environment. Also, confirm you have sendmail installed in the first
place ($ which sendmail — should return something like /usr/sbin/sendmail). I
found a good guide at https://library.linode.com/email/exim/send-only-mta-
ubuntu-12.04-precise-pangolin, but the gist is:
apt-get install exim4-daemon-light mailutils
followed by:
dpkg-reconfigure exim4-config
which will get you to an interactive editor.

== This solution helped 4 people ==
Should be a simple fix. You just need to install Postfix which does the actual
emailing.
sudo apt-get install postfix
You want to run that from a terminal (and not the software centre) because it
needs to ask you a few setup questions. You should be find to just accept all
the defaults (local-only, etc).

With thanks & praise to God! With thanks to all the many who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music & music license: https://www.bensound.com/royalty-free-music | Images & images license: https://stocksnap.io/license and others | With thanks to user Zanna (https://askubuntu.com/users/527764), user vrobinson (https://askubuntu.com/users/276468), user Oli (https://askubuntu.com/users/449), user Jorge Castro (https://askubuntu.com/users/235), user JM at Work (https://askubuntu.com/users/14951), user Felix (https://askubuntu.com/users/310914), user Dima L. (https://askubuntu.com/users/162670), user deputy_D (https://askubuntu.com/users/526154), user con-f-use (https://askubuntu.com/users/17789), user colan (https://askubuntu.com/users/24860), and the Stack Exchange Network (http://stackoverflow.com/questions/47609). Trademarks are property of their respective owners. Disclaimer: All information is provided “AS IS” without warranty of any kind. You are responsible for your own actions. Please contact me if anything should be amiss at Roel D.OT VandePaar A.T gmail.com.

source

by Roel Van de Paar

linux smtp client