{"id":17179108,"url":"https://github.com/flashmob/mbox","last_synced_at":"2025-04-13T17:11:45.831Z","repository":{"id":61839371,"uuid":"336170413","full_name":"flashmob/mbox","owner":"flashmob","description":null,"archived":false,"fork":false,"pushed_at":"2021-02-05T07:11:17.000Z","size":13,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T08:01:52.916Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flashmob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-05T05:11:02.000Z","updated_at":"2024-06-06T03:37:38.000Z","dependencies_parsed_at":"2022-10-22T05:00:42.289Z","dependency_job_id":null,"html_url":"https://github.com/flashmob/mbox","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashmob%2Fmbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashmob%2Fmbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashmob%2Fmbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashmob%2Fmbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flashmob","download_url":"https://codeload.github.com/flashmob/mbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248750108,"owners_count":21155686,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T00:24:52.814Z","updated_at":"2025-04-13T17:11:45.796Z","avatar_url":"https://github.com/flashmob.png","language":"Go","readme":"\n# mbox library for Go (Golang)\n\n\nThis library implements the popular `mbox` format for storing email messages.\n\nIt implements the `io.Reader` and `io.Writer`, as well as `io.Closer` ready to plug in to your project.\n\nThe library has been written with streaming in mind. (i.e. data is read/written in chunks).\nThe writer does not use any internal buffers (other than the slice provided). \nBoth the reader and writer work on chunks of any size, especially handy if you use `io.CopyBuffer` or use in TCP streams and so on.\n\nUnit tests coverage at \u003e 90%, and include some edge cases. No external dependencies.\n\n## Did you know?\n\n\n`mbox` has many variants! This library implements the common `mboxrd` variant, popularized by `qmail`.\n\nFor a description of the format, see http://qmail.omnis.ch/man/man5/mbox.html\n\n## Using\n\n`import \"github.com/flashmob/mbox\"`\n\n### As a Writer\n\nExample: read a message `message.eml`, encode and append to the `mbox` file.\n\n\n```go\n\n// buf is our working buffer, \n// in this example 4096 bytes is the usual block size of a SSD\nbuf := make([]byte, 4096)\n// input\nfin, err := os.Open(\"./message.eml\")\n// output (mbox files are append-only)\nfout, err := os.OpenFile(\"./mbox\", os.O_APPEND|os.O_WRONLY, 0640 )\nmbox := mbox.NewWriter(fout)\nerr = mbox.Open(\"test@example.com\", time.Now())\nif err != nil {\n   return err\n}\n// do the encoding\n_, err = io.CopyBuffer(fout, fin, buf)\nif err != nil {\n   return err\n}\nerr = mbox.Close()\nif err != nil {\n  return err\n}\n\nfin.Close()\nfout.Close()\n\n```\n\n\n### As a Reader\n\n```go \n\n// buf is our working buffer, \n// in this example 4096 bytes is the usual block size of a SSD\nbuf := make([]byte, 4096)\n// output\nfout, err := os.OpenFile(\"./message.eml\", os.O_WRONLY, 0600)\n// input (just read the first message)\nfin, err := os.Open(\"./mbox\")\nmbox := mbox.NewReader(fin)\n// do the decoding\n_, err = io.CopyBuffer(fout, fin, buf)\nif err != nil {\n    return err\n}\n// Note: \n// we could read another message here by using io.CopyBuffer with a new destination\n// the mbox reader (fin) will automatically read in the next message sequentially\nerr = mbox.Close()\nif err != nil {\n    return err\n}\nfin.Close()\nfout.Close()\n\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflashmob%2Fmbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflashmob%2Fmbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflashmob%2Fmbox/lists"}