Saturday, January 29, 2011

installing a mail server to be used with PHP

Hi,

I have a dedicated server which I want to use to run a LAMP stack on. Now, I want to use php mail on that server.

How do I go about doing that?

PS: it is an ubuntu server.

Thanks

  • You need to setup your system as a mail server. Have a look at the following documentation: https://help.ubuntu.com/community/MailServer

    harshath.jr : I already came across this, but I'm new to setting up a mail server. I still don't have the basics, like what MTAs and MDAs do
    From Dominik
  • I prefer to have PHP use our regular mail server as it has the correct reverse DNS entries, security patches etc.

    If you use PHPMailer you can easily use your regular SMTP server - it does authentication too!

    harshath.jr : I need to install an SMTP server, i think. We have a dedicated server, not a shared host.
    Jon Rhoades : @harshath.jr Not sure what difference a dedicated or shared host makes. You must already have an email server - why not use it?
    harshath.jr : okay, what does "it does authentication too" mean? what kind of authentication are you talking about? who is authenticating to whom?
    Jon Rhoades : @harshath.jr Err... SMTP authentication - where you log into your SMTP server with your Username and Password to send email.
    harshath.jr : okay.... so if I install sendmail on my server, will I be able to send emails via PHP? (I know this question sounds very lame. I have absolutely no clue as to how to set up a mail server, and how to have php use it.)
  • For the Windows People: Hamster Classic is the way to go if your developing on Windows. You can get a test mail server running in just a few minutes and it allows to to inspect the mail packets in detail.

    From djangofan
  • Personally I prefer Exim, the below steps will get a system up and going for outgoing mail only.

    • Make sure the hostname is setup correctly
    • Install apt-get install exim4 exim4-daemon-light
    • At the configuration step answer the questions this way
      • Type of mail configuration: Internet site
      • System name: the fqdn for your server
      • IP-Address to listen on: 127.0.0.1 (with this address incoming mail is not possible)
      • Other destinations which is accepted: empty
      • Domains to relay for: empty
      • machines to relay for: empty
      • Keep DNS minimal: yes
      • Delivery method for local mail: Maildir
      • Yes Split configs

    Once exim is already configured you can run though this setup again by using the command dpkg-reconfigure exim4-config

    You might want to consider choosing to use the Smarthost options during the above setup and direct your mail through an already established SMTP server that will relay for you. The other server will have probably already handled getting the DNS records setup correctly.

    harshath.jr : +1 thanks. A few questions, though: what is an MTA and an MDA? is Exim an MDA or MTA or both? And how will I configure PHP mail to use this server? Also, I only need to send out email from the server, receive email. So do I need an MDA? And what is sendmail?
    Zoredache : MTA = Mail Transfer agent (http://en.wikipedia.org/wiki/Message_transfer_agent) -- MDA = Mail Delivery agent (http://en.wikipedia.org/wiki/Message_delivery_agent) -- The sendmail is one of the oldest *nix MTAs. It included a binary that almost all other *nix MTAs emulate that allows you to send email through a command. Exim performs both MTA and MDA functions, so with exim you get what you need. As for how to send via PHP, I like to use PHPMailer (http://stackoverflow.com/search?q=phpmailer)
    harshath.jr : okay, so what does an MTA do? to send mail, do I need an MTA or an MDA? if I install sendmail, and decide to use PHP mail() function instead of PHPMailer, how do I tell php to use sendmail?
    From Zoredache

0 comments:

Post a Comment