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?
From the mail manual of php:
This means you have to install some sort of mailserver and configure php to use it. Usually this mailserver is postfix in Ubuntu. However - if the php side you are coding will eventually be stored on a hosting service's side (e.g. xmission), a mail server will most likely allready be installed there. In that case just test your site online instead of locally.
If you need to test it on your own system or mean to host it on your own home-server than proceed with:
Installation: postfix /
The rest of the install options depend on your choice of this general configuration.
Most likely you will choose a satellite install. That means mail will be send using an extern provider. As smtp-server (outgoing mail server) you will then have to specify your providers smpt. The rest of the options is self explanatory.
Post Installation Configuration
Most smtp-servers require a password authentication to send mail. So postfix will need to know that password. Also there are things like encryption to consider (which you'll have to google). This is how you configure postfix using password authentication (sasl):
This should do it in most of the cases. Yet some smtp providers require a specific address as the sender or encryption.
Related: PEAR::Mail interface might also be of interest to you.
Gmail (and perhaps other services) may not like it that you are attempting to send mail this way as it could be deemed insecure by their standards, and would block your attempt i.e. nothing will happen on the screen or someplace of the whole process would block your authentication. Also your POP3 must be enabled.
To counter that see here. (If you want to be on the safe side, then create a dummy Gmail account)
PHP requires an SMTP client to send mail. You could install a full-featured mail transfer agent (MTA) like Postfix 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.
Create a new configuration file:
...with the following configuration information:
You need to put your own configuration information within each "<" and ">". For host/username/password, use your normal credentials for sending mail through your mail provider.
Tell PHP to use it
Add this single line:
Set up logging
Add these lines to the new file:
If you'd like to be able to view the logs as yourself, you should add yourself to the www-data group.
This is an old question and there are worthy answers above, but I needed
which will get you to an interactive editor.
As already noted, postfix would be an overkill if you just need to send emails from php while developing applications on your home computer.
I personally use very simple and lightweight package ssmtp. It will use any smtp server to send outbound emails. Install it by running:
(Provide your gmail username & password. Of course you can use any other SMTP server).
Now make sure that your php.ini has correct
Reload apache and your php should be able to send outgoing emails now.
Should be a simple fix. You just need to install Postfix which does the actual emailing.
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).