OS X: sending mail to localhost

前端 未结 6 771
臣服心动
臣服心动 2021-02-04 20:07

For testing purposes I want send mail to my localhost user account rather than my webserver. I am unsure how to do this using mail.app. Any help would be appreciated.

6条回答
  •  时光说笑
    2021-02-04 20:38

    I'm looking to login into my (local) mail server, access a mailbox, and do some parsing. So, I assume there's a mail server running locally but not sure how to access it

    The local mail isn't stored in a POP3/IMAP server, but rather using a UNIX'y mbox. A file stored in /var/mail/ (the file-name is the users login)

    For example..

    $ mail dbr
    Subject: hi
    test
    ^d # ctrl+d (EOF)
    $ cat /var/mail/dbr 
    From dbr@parabola.local  Tue Dec 30 13:43:57 2008
    Return-Path: 
    X-Original-To: dbr
    Delivered-To: dbr@parabola.local
    Received: by parabola.local (Postfix, from userid 501)
            id 4FEA1158E36; Tue, 30 Dec 2008 13:43:57 +1030 (CST)
    To: dbr@parabola.local
    Subject: hi
    Message-Id: <20081230031357.4FEA1158E36@parabola.local>
    Date: Tue, 30 Dec 2008 13:43:57 +1030 (CST)
    From: dbr@parabola.local (dbr)
    
    test
    

    Not sure about Ruby (I had a search around, but couldn't find anything, although there is undoubtably a module for this), but I know Python has a maildir.mbox module, which would use in the following way:

    >>> msgs = mailbox.mbox("/var/mail/dbr")
    >>> for msg in msgs:
    ...     print "Subject:", msg['subject']
    ... 
    Subject: hi
    

提交回复
热议问题