First: How do I know if my system is able to send an e-mail? Second: How do I configure if it can't send an e-mail at the moment?

Because I went to /etc/php5/apache2/php.ini and added this:

sendmail_path = "/usr/sbin/sendmail -t -i"

Then, I restarted Apache, but when I tried a simple mail, e.g

if(mail($to,$subject,$message,"FROM: $from")){
   echo "mail sent";
} else {
   echo "sending failure";
}

It failed, did I miss something ?

link|improve this question

33% accept rate
It sounds like you are way in over your head and might want to consider hiring a consultant to assist you. – TylerShads Nov 20 '11 at 22:40
feedback

2 Answers

You need to configure a mail server on your host. Serverfault's search yields this link which explains the procedure

link|improve this answer
how to configure that? ..on windows I only add something like this, at the php.ini file.. SMTP = mail.myispprovidersite.net smtp_port = 25 ..how bout on linux ? – sasori Nov 20 '11 at 14:30
Have you tried doing just that on linux (php.ini should be in /etc/php5/apache2/php.ini)? Anyway, it's usually a good idea to configure a local mail server, since also other services want to use it. Usually, it's configured as a satellite system which forwards all mail to your ISPs mail server. – danimo Nov 22 '11 at 7:48
You can configure your MTA on installation (apt-get install postfix) or at anytime (dpkg-reconfigure exim4-config for exim, dpkg-reconfigure postfix for postfix, I recommend postfix). A menu will guide you through the setup process. – danimo Nov 22 '11 at 7:50
Can't add a comment to the poster below, so let me answer: as long as you are configure your mail server to forward mail to your ISP using your SMTP login credentials, the chance to be blacklisted is the same as for a direct forward. I agree howerver that correctly configuring a local mail server adds administration overhead. – danimo Dec 1 '11 at 17:24
feedback

In my experience I found maintaining a mailing server is not necessarily the best practice. It can be problematic if your server falls into blacklists etc.

I prefer using any one of free/paid mailing services available on the web instead. I use simple standalone scripts (ie: http://caspian.dotconf.net/menu/Software/SendEmail/) to access these services via POP/IMAP in my applications, which are also easier to configure.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.