Slashdot Mirror


Offline Mail Queues w/ Mac OS X?

Zorton asks: "After switching to Mac OS X (10.2) for my primary work/play environment I started to customize the system as I would a Linux or BSD system. One of the first things I wanted to tackle was getting mail into the machine and enabling offline mail queuing (as this is a laptop that roams quite a bit). After installing Fink I was happy to see some of my favorite MTAs available. However I was disappointed to discover there seems to be no mechanism similar to /etc/network/if-up.d (or similar). I spent a bit of time poking and prodding the system but the best I could come up with where some library functions listed on Apple's Developer Connection website. Has anyone tried to configure offline mail queues under Mac OS X 10.2? If you have how did you handle telling the MTA to transfer the mail you have queued up?"

48 comments

  1. THAT'S IT! by HaloZero · · Score: 1

    I knew there was something else I wanted to ask these people. *grumbles*

    I've been nagged to try and setup something like this. No, I've not given it much thought. Yes, I am interested in everyones ideas. Cool! Thanks for reminding me of this one. I hope it's fruitful.

    --
    Informatus Technologicus
    1. Re:THAT'S IT! by Anonymous Coward · · Score: 0, Offtopic

      Apple saugt Ziegetestikel und also tun Sie Sie. Auch Sie haben schlechten Atem.

  2. Umm, it's already there... by itwerx · · Score: 5, Insightful

    I'm not sure what you're needing to do but the Mail app which comes bundled with OSX does all that out of the box. The mail spools for each user are under their respective /user/joeblow/Library/Mail/Mailboxes They're even in standard 'nix spool format!
    If you need to use a different app just point it to the right folder and let OSX do the rest...

    1. Re:Umm, it's already there... by phyxeld · · Score: 4, Informative

      If you want to tie events to changes in your location, ie when you select something different from AppleMenu->Location->..., have a look in /System/Library/SystemConfiguration/Kicker.bundle/ Resources/ (removing the slashcode-added space...)
      XML files and shell scripts powering the mac location manager... never thought I'd see the day :)

      --
      __
      Choose mnemonic identifiers. If you can't remember what mnemonic means, you've got a problem. - Larry Wall
  3. google cache of the man page.... by Anonymous Coward · · Score: 1, Insightful
    sendmail -q

    like you normally do....

    1. Re:google cache of the man page.... by austad · · Score: 5, Informative

      Out of the box, sendmail is not set up correctly on OS X, at least in 10.2.

      I ripped it out and installed Postfix on my iBook instead. I pointed Mail.app at localhost for it's SMTP server, and even when I'm offline, my mail will queue up. However, the only reason I did this is because my ISP's SMTP server sucks, and I wanted to bypass it.

      Mail.app will already do offline queues, so you really don't need to do anything special. If it can't send a message, it will tell you, and you just click the "Send Later" button.

      --
      Need Free Juniper/NetScreen Support? JuniperForum
    2. Re:google cache of the man page.... by foniksonik · · Score: 5, Informative

      Here's a few links to help out those who want to set up sendamil correctly (with bind et al thrown in for good measure).

      http://www.macosxhints.com/article.php?story=200 20 825230925806

      Pretty basic, but a quick start...

      http://www.sial.org/sendmail/macosx/8.12.2-jagua r/

      More technical and in depth for those who know and care.

      And of course you can also google for "sendmail os x 10.2" like I did and find other resources.

      --
      A fool throws a stone into a well and a thousand sages can not remove it.
    3. Re:google cache of the man page.... by foniksonik · · Score: 1, Redundant

      You can use cron jobs to automate sendmail stuff too.. just like any other *nix. Of course there are probably more elegant ways to do it.

      --
      A fool throws a stone into a well and a thousand sages can not remove it.
    4. Re:google cache of the man page.... by austad · · Score: 5, Informative

      Sendmail is the devil, install postfix. Postfix is both faster and much easier to administer (postconf -e command, instead of editing the evil sendmail.cf file by hand). You will have to install some extra packages to get it to compile (like pcre, and the latest Berkeley DB), but it's worth it. Plus, postfix has a much shorter history of security issues, and runs as a non-priveledged user to reduce the chance of something really bad happening if a new exploit is discovered.

      Just google for "postfix os x 10.2" to find install instructions.

      How do I know postfix is better? I built several large mail clusters for a large online financial site using sendmail, qmail, and postfix. Postfix well outperformed the other two (the versions in the last year anyway, qmail used to be the fastest). And with a large number of machines, postfix was a dream to administer.

      --
      Need Free Juniper/NetScreen Support? JuniperForum
    5. Re:google cache of the man page.... by preggie_greggie · · Score: 2, Informative

      This is a great tutorial detailing the steps to get postfix going on mac os x. It's a bit outdated (probably written for 10.0 or 10.1) but it's not very difficult to figure out what to do for jaguar from it.

    6. Re:google cache of the man page.... by sporty · · Score: 2

      Opinions are like assholes, everyone has one. :)

      The default install of sendmail is as easy to admin as qmail. A lot of the simple features are enabled by default, like virtualhosts, access lists, etc..

      In terms of speed, for a machine that's not churning millions of mail a day, it's "good enough". Don't need a club to kill mosquitos :)

      --

      -
      ping -f 255.255.255.255 # if only

    7. Re:google cache of the man page.... by raju1kabir · · Score: 1
      In terms of speed, for a machine that's not churning millions of mail a day, it's "good enough". Don't need a club to kill mosquitos

      Sure, but Sendmail is a resource hog, and you could be using those resources to do other things. No point tiring yourself out swinging a flyswatter around if there aren't any mosquitos.

      --
      "Patriotism is your conviction that this country is superior to all other countries because you were born in it." -- GBS
    8. Re:google cache of the man page.... by sporty · · Score: 2

      But it's not a resource hog. Works quiet well at that.

      --

      -
      ping -f 255.255.255.255 # if only

  4. Probably part of Cocoa or Carbon by fordgj · · Score: 1

    Though I don't have a specific answer to your problem, my guess is that a library such as this might be accessible through the Cocoa or Carbon API's. I know that Adium (which is open source) will reconnect to it's server if it loses it's connection. My experience is that the network utilities work differently in some cases than they do under linux, probably due to their BSD heritage. Ifconfig will list all the interfaces that are up with the command 'ifconfig -u.'

    1. Re:Probably part of Cocoa or Carbon by vincent99 · · Score: 1

      Adium does that by sending an IM to itself every once in a while and then dis/reconnecting if it never hears from itself.

      --
      -- V
  5. Offline Mail/Online mail by Anonymous Coward · · Score: 0

    offline = spam;
    online = mail;

  6. Mail.app out box by foniksonik · · Score: 4, Informative

    Mail.app will queue your outbound mail in a standard way... throws them in to the 'Out' box and will send them first opportunity. You could also try out eudora which has all kinds of nifty extras.

    Don't forget to set up rules in Mail.app for cc to yourself or whatever. Finally there are lots of 'hidden' features to Mail... that are standard on other mail progs... like bcc, that you just have to turn on via one of the menus.

    --
    A fool throws a stone into a well and a thousand sages can not remove it.
    1. Re:Mail.app out box by EddydaSquige · · Score: 1

      Speaking of bcc, I was able to turn it on in 10.1 but I did a clean install for 10.2 resetting everything. I forgot how to turn on bcc, if anyone could post a way to do it, that would be swell.

    2. Re:Mail.app out box by stux · · Score: 2

      edit menu, add bcc header

      stumped me for a bit until a colleague pointed out where it had moved too ;)

      --

      ---
      Live Long & Prosper \\//_
      CYA STUX =`B^) 'da Captain,
      Jedi & Last *-fytr
  7. If you are using ppp, pppoe, or similar... by Graff · · Score: 4, Informative

    I do know that pppd calls a script every time its connection goes up or goes down. You may be able to write a script to do your mail transfers with this script.

    When the connection is made it calls the shell script at: /private/etc/ppp/ip-up

    When the connection is broken it calls the shell script at: /private/etc/ppp/ip-down

    If you don't use ppp or pppoe (or anything else that uses pppd) then maybe there are similar scripts in other places. Hope this helps.

  8. Develop something like /etc/network/if-up.d by tbien · · Score: 2, Informative
    Hi,

    I think you could easily develop something with similar functionality you want to have if you use the SystemConfiguration Framework - provided that you have some C/C++/Objective-C knowledge.

    More informations about the framework mentioned above can be found here (http://developer.apple.com/techpubs/macosx/Networ king/SysConfigOverview926/index.html ).

    Read the "Dynamic Agents" chapter...

  9. Hello? Cron? by kwerle · · Score: 4, Informative

    Shell scripting was invented for a reason. Don't copy this script and expect it to work. But do copy the idea.

    crontab:
    * * * * * /somepath/checkping.zsh

    /somepath/checkping.zsh:
    #!/bin/zsh
    if ([ test -e /tmp/connected.txt ])
    then
    if (ping -c 1 www.apple.com)
    then
    # we are already up
    else
    # we went down
    rm /tmp/connected.txt /somepath/wentdown.sh
    fi
    else
    if (ping -c 1 www.apple.com)
    then
    date > /tmp/connected.txt /somepath/wentup.sh
    else
    # we were already down
    fi
    fi

  10. Apple Script by Influencial · · Score: 1

    I'm pretty sure that apple script has the ability to interface with your MTA.

    --
    - Any fool can criticize, condemn, and complain, and most fools do.
  11. diffrent ideas by Zorton · · Score: 5, Insightful

    thanks for everyones input

    I think the underlying problem i'm having is the lack of any ip-d up script or anything like that. It seems to be obvious now after reading some of the comments posted, that the short term solution would be to use Mail app or point something else towards Mail.app's mail dir. I still would like to find out how the location manager does it's thing (Under the apple menu -> location). The API for it seems to be very well documented and perhaps I will end up coding something similar to a interface up script. In the meantime all I will do is install postfix and have it default upon startup to offline mode. Then i'll run a cron job about every minute or to check for up interfaces that have come up (ifconfig -u, and check the routing tables). Not quite as elegant as i've done in the past on a debian system using qmail but should get the job done. I think with a system like that I could grab e-mail from my pop box using another cron job (fetchmail?), and have a offline mail queue ready to go.

    What do you think? Has anyone taken a closer look into the location manager's inner workings? I find it difficult to believe apple didn't provide any provision for advanced configuration of the interfaces (changing the MAC address or perhaps the MTU based on diffrent locations and options).

    Thanks

    1. Re:diffrent ideas by Anonymous Coward · · Score: 0

      Your spelling enables you to become a slashdot editor.

      You, sir, are an idiot.

    2. Re:diffrent ideas by Brownian+Motion · · Score: 3, Informative

      Try reading this nice article about updating SAMBA when your ip changes. Since it shows you how to run a shell script when your ip changes, hopefully this will allow you to do what you want.

      http://www.culater.net/osd/samba/samba.html

      There's some info from Apple: http://developer.apple.com/techpubs/macosx/Network ing/SysConfigOverview926/index.html?http://develop er.apple.com/techpubs/macosx/Networking/SysConfigO verview926/SysConfigOverview926c.html

      And it's not what you want, but if you want to change locations from the command line, you need to look at the nice command /usr/sbin/scselect. (Take a look in /usr/sbin and /usr/bin for a bunch of nice Apple Command line tools. Rare if it has a man page though.)

      What I want to be able to do is to be able to run a script when my laptop wakes up. Still haven't found something nice for that. I can run a program in the background all the time that gets notified of power events, but I'm sure that Apple already has something running which will do this. (I want to use a command line tool to sniff for wireless access points, and depending on what is found, switch my location. I can do it all...if I run the script manually, I just want it to run automatically on wakeup.)

    3. Re:diffrent ideas by aeijdenb · · Score: 3, Informative

      /System/Library/Frameworks/SystemConfiguration.fra mework/Versions/A/Headers/SCNetwork.h

      SCNetworkCheckReachabilityByName
      or
      SCNetworkCheckReachabilityByAddress

      will both "determines if the given network host/node name is reachable using the current network configuration."

      They will NOT cause a modem user to automatically dial.

    4. Re:diffrent ideas by klez23 · · Score: 3, Informative

      in case you didn't see the previous post above, i thought i'd restate that there IS a mechanism just like ip-d-up. it's a script called /etc/ppp/ip-up (and there's a corresponding /etc/ppp/ip-down). They probably don't already exist, but you can create them. I've got it chmod 700. My ip-up reads as follows (note that "sendmail" & "mailq" actually refer to my postfix executables):

      #!/bin/sh

      #send queued messages (really uses postfix)
      Q=`/usr/local/sbin/mailq`
      if [ "$Q" != "Mail queue is empty" ]; then
      logger -t $0 sending queued messages
      /usr/local/sbin/sendmail -q
      fi

      #update dyndns entry
      /etc/ppp/ip-up.ddclient $*

    5. Re:diffrent ideas by Zorton · · Score: 1

      Yeah I did see you post earler on. I agree it would work perfectly for PPP but I seldom use PPP. Most of what I use is wireless via PC card or straight eithernet.

    6. Re:diffrent ideas by Zorton · · Score: 1

      this is almost exactly what I wanted. I think I just may be able to hack something together using the command line tool, or at the very worst have to code a bit in perl (oh woe is me! :)

      Thanks

    7. Re:diffrent ideas by Anonymous Coward · · Score: 2, Informative

      There's a great article at Stepwise written by Graham Orndorff that might help you out. You can find it at: http://www.stepwise.com/Articles/Workbench/eart.in dex.html

  12. Re:What about finding it yourself? by arkane1234 · · Score: 1

    have one for you: I would like to use my old dos apps but without using Virtual PC or bochs because I don't like them.

    Then don't run a Macintosh if you don't want to run virtualizations of some kind. First off, your running a Unix-like system, and second off your running a completely different architecture. Those two things combined make it impossible to do without either Virtual PC or Bochs. Maybe VMWare if they come out with a OS/X version, but those are your choices.

    --
    -- This space for lease, low setup fee, inquire within!
  13. Some ressources from O'Reilly by paulio · · Score: 4, Informative

    Check out Mac OS X for Unix Geeks from O'Reilly
    http://www.oreilly.com/catalog/mosxgeeks /
    and
    Top Ten Mac OS X Tips for Unix Geeks
    http://www.oreillynet.com/pub/a/mac/2002/10 /22/mac forunix.html

    1. Re:Some ressources from O'Reilly by paulio · · Score: 1

      Ooops...
      http://www.oreillynet.com/pub/a/mac/2002 /10/22/mac forunix.html

  14. Will this handle changes to outgoing mail servers? by evil_roy · · Score: 2

    I change locations a lot. I use entourage and although I use the location manager which handles the network changes fine , I have to change smtp servers manually to send mail depending on where I am. I haven't found a way around this with switching locations. Does this suggestion help solve my problem?

  15. Er, configure sendmail? by MrChuck · · Score: 5, Informative
    I've been using sendmail for over a decade.

    UUCP and PPP meant spool up mail, send it periodially.
    UUCP ran periodically (cron), when PPP started up, a startup script would run a sendmail queue runner.

    The only difference here is (1) determining when you are "on the net" via ethernet or wireless and (perhaps) (2) using TLS and SMTP AUTH to allow you to send ANY TIME you are on ANY net - you authenticate yourself to a machine on the net and use TLS to encrypt the transaction. Or setup an IPSec connection to your server. Or use UUCP over SSH (scary, but I've done it).

    Configure sendmail in "queue only mode" and treat it like an occasionally connected machine. This is basic (for mail).

  16. Re:Will this handle changes to outgoing mail serve by phyxeld · · Score: 4, Informative
    I change locations a lot. I use entourage and although I use the location manager which handles the network changes fine , I have to change smtp servers manually to send mail depending on where I am. I haven't found a way around this with switching locations. Does this suggestion help solve my problem?
    Can you ssh to a server near any of your smtp servers?
    If so, that would be the ideal method. All my accounts use localhost:2525 as the smtp server, and I have an ssh command something like ssh user@sshhost -C -v -L 2525:smtphost:25 -L 1101:pophost:110 to tunnel everything. If your ssh host does SSH2 (protocol version two, not version two of the software) you can use the -f -N options to background it, which makes it easy to start and stop from a location-triggered shell script. (and naturally, you'll want to use localhost:1101 as your pop server now, so that too will be encrypted)

    Doing unencrypted pop and smtp from a laptop is never a good idea. Even if you're careful, eventually you'll probably leave your mail client open while you use your machine within range of some random wireless network, and then you'll be sending your cleartext password over not just the internet but also the public airwaves...

    In addition to the security, another benefit to using ssh tunnels for pop and smtp is that your mail client can only get packets out to the internet when the ssh tunnel is up. It doesn't know the name of the actual internet servers, and if you killall ssh, connections to localhost2525 and localhost:1101 are simply refused and you've made no noise at all on the network. And another benefit is that you can have a local port open from behind any firewall (ie, use -R 8080:localhost:80 in your ssh command and http://sshhost.yourisp.net:8080/ will have your local webserver on it). I often use this for testing websites from behind the firewall at work.

    Ok, I could go on more, but the point here is that ssh is damn cool.
    --
    __
    Choose mnemonic identifiers. If you can't remember what mnemonic means, you've got a problem. - Larry Wall
  17. Re:Will this handle changes to outgoing mail serve by Anonymous Coward · · Score: 0

    Set up a different Mail.app account for each location. Each account will have their own SMTP server configured accordingly. So when you come to a new place, just switch "Location", open the Mail.app, switch to the appropriate account and start sending and receiving your mails.
    I assume that you know how to set up a new account in Mail.app.

  18. Where are /. apple people? by gqgreg · · Score: 1

    Why has nothing been posted to apple.slashdot.org in over two days? Is there simply no apple news?

    --
    Powerbook G4/1.5GHz 12", Toshiba Satellite 1135-S1554
    1. Re:Where are /. apple people? by Anonymous Coward · · Score: 0

      They are waiting for the next software update to come out/be rumoured about.

      Thank you for your enquiry.

  19. Postfix Zealots by Anonymous Coward · · Score: 0

    Why do people really believe that Postfix is easier?

    Follow the five step readme in /etc/mail on OS X>10.1.5, and sendmail will provide all the functionality 90% of ibook users would ever want.

    For the other 10%, RTFM, it's still quicker than installing postfix, and current versions of sendmail are just as secure, and unless you're using your ibook to send >10000 spams an hour, sendmail is plenty fast.

  20. Re:Will this handle changes to outgoing mail serve by fasta · · Score: 1
    I have the same problem, but I have found that one can set up several SMTP servers for the same account, then after one of them fails, the alternative servers are offered. Once the new server is selected, it is used for the remainder of the session.


    The ssh solution is much more elegant (and secure), but out-of-the-box, things work pretty well.

  21. SystemConfiguration.framework is your friend by mccare · · Score: 1

    if you want to get your hands "dirty" (meaning programming) you might want to look at the system configuration framework. You can hook up for notifications of the configd whenever an entry changes (e.g. an interface goes down). This is coded in C, but if you know how to write a daemon, it should be pretty easy to get those notifications and execute shell scripts.

  22. Sendmail is for smart people. by MrChuck · · Score: 2
    I too was confronted by someone who had a postfix setup running faster than sendmail. He too was quite loud about it.

    His well tuned Postfix was much faster than his untuned unix running an untuned Sendmail.

    We tuned Sendmail. It smoked Postfix (200k+/hour/machine) before using better hardware (faster disks, not more CPUs).

    So if Sendmail is too hard for you, then perhaps Unix (therefore Linux) is too hard and you should go back to Windows.