Sending email from laptop through Postfix

12
2013-08
  • Questioner

    My laptop running ubuntu.

    I've just finished running:

    sudo apt-get install php-pear
    sudo pear install mail
    sudo pear install Net_SMTP
    sudo pear install Auth_SASL
    sudo pear install mail_mime
    sudo apt-get install postfix
    

    and I choose "website" in the configuration instead of "localhost"

    and then I send email to gmail. But the email still not arrived..

    I dont know why this not works.

  • Answers
  • gravyface

    It sounds like you're setting up a local development environment on your laptop for Drupal.
    If this is true, then there's a couple of ways you can go about this (note: I don't use Ubuntu Desktop very much besides Web surfing, so there may be point-and-click ways to achieve the following):

    • send all your test emails to a local account. You need to configure Postfix as 'local only' (if you run sudo dpkg-reconfigure postfix it'll ask you again how you want to configure your mail system. Choose local only, and choose your hostname.local or whatever as your mail domain) and then you can use mutt as a simple mail client through Terminal.
      This is probably the easiest and again, if you're doing dev work, you don't have to worry about sending mail out to real addresses by mistake, SMTP blocking on home connections, or even an Internet connection for that matter.

    • If you really need to send to Internet email addresses, you'll have better luck setting up gmail as your smarthost and reconfiguring Postfix as "Satellite with Smarthost" in the dpkg-reconfigure postfix setup. There's a bit more to it, but this has been covered quite a bit on ServerFault. By using gmail as your smarthost on an alternative port (tcp 587), you can get around ISP firewalls blocking SMTP and should be able to send email out of most Internet connections.

    As for Drupal, it's been a while, but I believe by default (and as with most PHP applications), it'll use whatever is configured in the /etc/php5/apache/php.ini file's sendmail_path setting, but by default, it'll use Postfix's built-in sendmail wrapper on the localhost (your laptop) so you shouldn't need to change anything there.

    Perhaps someone else can clarify that and I'll update my answer accordingly.


  • Related Question

    email - How can I catch mail that my development server is generating so I can view it, but not send it?
  • Chrisbloom7

    When I was developing on a PC, I used a program called PostCast (http://www.postcastserver.com/) to act as my local SMTP server and catch any messages that my web applications generated. It then had a GUI where I could view the messages as if I were on the receiving end. The server could also be configured to never actually send the messages but hold them indefinitely until I manually removed them. This worked out great especially when I was testing against real customer data.

    I've since moved on to a Mac and I've yet to find a good way of doing the same thing. For now, I've just been manually changing all of the email addresses to my own and viewing them in Gmail, but I would prefer to be able to mimic the functionality I had in PostCast. Is there a similar way of doing this on Snow Leopard? (I've currently got PHP configured to use the built-in postfix mail server. FWIW, I don't use any desktop mail applications [e.g. Mail.app] and shouldn't really ever need to actually send email directly from my machine.)


  • Related Answers
  • Shane O'Grady

    I know this is a late response, but there is a native Mac app to do this now: MockSMTP. Works great and does exactly what you want.

  • Everett

    I've done this using DoveCot on my Mac Mini Server (running OS X 10.6 Server). I can configure it to cache sent messages to a folder, and since the Mini Server is the web server, messages are sent from it (the web server uses DoveCot for outgoing mail). I hope this helps.