Skip to content

Commit

Permalink
Merge branch 'release/v0.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
axllent committed Jul 11, 2024
2 parents e70f2e5 + 4841c5c commit 84bea85
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 8 deletions.
47 changes: 47 additions & 0 deletions .chglog/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Changelog

Notable changes to Mailpit will be documented in this file.

{{ if .Versions -}}
{{ if .Unreleased.CommitGroups -}}
## [Unreleased]

{{ if .Unreleased.CommitGroups -}}
{{ range .Unreleased.CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{ range .Versions }}
{{- if .CommitGroups -}}
## [{{ .Tag.Name }}]

{{ if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end -}}
{{ end }}
{{ end -}}
{{ end -}}

{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end }}

{{- if .MergeCommits -}}
### Pull Requests
{{ range .MergeCommits -}}
- {{ .Header }}
{{ end }}
{{ end }}
{{ end -}}
12 changes: 12 additions & 0 deletions .chglog/RELEASE.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{ if .Versions -}}
{{ range .Versions }}
{{- if .CommitGroups -}}
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}
{{ end -}}
46 changes: 46 additions & 0 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/axllent/mailpit
options:
commits:
# filters:
# Type:
# - feat
# - fix
# - perf
# - refactor
commit_groups:
title_maps:
feature: Feature
fix: Fix
# perf: Performance Improvements
# refactor: Code Refactoring
sort_by: Custom
title_order:
- Feature
- Chore
- UI
- API
- Libs
- Docker
- Security
- Fix
- Bugfix
- Docs
- Swagger
- Build
- Testing
- Test
- Tests
- Pull Requests
header:
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
pattern_maps:
- Type
- Scope
- Subject
notes:
keywords:
- BREAKING CHANGE
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Changelog

Notable changes to Mailpit will be documented in this file.

## [v0.0.6]

### Chore
- Automatically generate email headers if input does not contain valid email headers ([#10](https://github.com/axllent/mailpit/issues/10))
- Add changelog


## [v0.0.5]

### Feature
- Add Message-Id and Date headers (if missing)

### Fix
- Prevent additional "\r\n.\r\n" after DATA is over ([#10](https://github.com/axllent/mailpit/issues/10))

### Pull Requests
- Merge pull request [#9](https://github.com/axllent/mailpit/issues/9) from axllent/dependabot/github_actions/wangyoucao577/go-release-action-1.51
- Merge pull request [#8](https://github.com/axllent/mailpit/issues/8) from axllent/dependabot/github_actions/wangyoucao577/go-release-action-1.50
- Merge pull request [#7](https://github.com/axllent/mailpit/issues/7) from axllent/dependabot/github_actions/wangyoucao577/go-release-action-1.49
- Merge pull request [#6](https://github.com/axllent/mailpit/issues/6) from axllent/dependabot/github_actions/wangyoucao577/go-release-action-1.46
- Merge pull request [#4](https://github.com/axllent/mailpit/issues/4) from axllent/dependabot/github_actions/github/codeql-action-3
- Merge pull request [#5](https://github.com/axllent/mailpit/issues/5) from axllent/dependabot/github_actions/wangyoucao577/go-release-action-1.41
- Merge pull request [#3](https://github.com/axllent/mailpit/issues/3) from axllent/dependabot/github_actions/actions/stale-9.0.0


### Pull Requests
- Merge pull request [#2](https://github.com/axllent/mailpit/issues/2) from axllent/dependabot/github_actions/actions/checkout-4
- Merge pull request [#1](https://github.com/axllent/mailpit/issues/1) from axllent/dependabot/github_actions/wangyoucao577/go-release-action-1.40


## [v0.0.3]

### Feature
- Add optional logging




7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ It was created primarily for use in Docker containers. Whilst there are many dif
- Static drop-in replacement for sendmail
- Configurable SMTP relay server, STARTTLS with PLAIN, LOGIN and CRAM-MD5 support
- SMTP on standard input (`sendmail -bs`)
- Auto-generates (if missing from input) `Message-Id`, `From` & `Date` headers


## Installation

- Static binaries can be found on the [releases](https://github.com/axllent/sndmail/releases/latest)
- Copy or symlink the `sndmail` executable to `/usr/sbin/sendmail`
- Copy or symlink the `sndmail` executable from `/usr/sbin/sendmail`
- Copy the `sndmail.conf.example` to `/etc/sndmail.conf` making any necessary edits to adjust to your SMTP relay server


### Install via bash script (Linux & Mac)

**Warning**: This will delete any existing /usr/sbin/sendmail!

Linux & Mac users can install it directly via:

```bash
sudo bash < <(curl -sL https://raw.githubusercontent.com/axllent/sndmail/develop/install.sh)
```

**Warning**: This will delete any existing /usr/sbin/sendmail
18 changes: 14 additions & 4 deletions cmd/mailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

// SMTP wrapper will send and optionally log the transaction
func smtpWrapper(from string, to []string, message []byte) error {
msg, err := injectHeaders(message)
msg, err := injectMissingHeaders(message, from)
if err != nil {
return err
}
Expand Down Expand Up @@ -140,11 +140,16 @@ func dataWithResponse(c *smtp.Client, msg []byte) (int, string, error) {
return c.Text.ReadResponse(250)
}

// Inject Message-Id and Date if missing
func injectHeaders(body []byte) ([]byte, error) {
// Inject Message-Id and Date if missing. The From address is also
// optionally injected if missing.
func injectMissingHeaders(body []byte, from string) ([]byte, error) {
msg, err := mail.ReadMessage(bytes.NewReader(body))
if err != nil {
return nil, err
// create blank message so lookups don't fail
msg = &mail.Message{}

// inject a new blank line before body
body = append([]byte(fmt.Sprintf("\r\n")), body...)
}

// add message ID if missing
Expand All @@ -159,6 +164,11 @@ func injectHeaders(body []byte) ([]byte, error) {
body = append([]byte("Date: "+now+"\r\n"), body...)
}

// set From header is missing
if msg.Header.Get("From") == "" {
body = append([]byte("From: <"+from+">\r\n"), body...)
}

return body, nil
}

Expand Down
2 changes: 1 addition & 1 deletion sndmail.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
### Default: empty
#auth-pass = password

### Log file - to log, get the absolite path to a logfile. The file must be
### Log file - to log, get the absolute path to a logfile. The file must be
### writable by all users using sndmail otherwise logging will silently fail.
### Default: empty
#log-file = /var/log/mail.log

0 comments on commit 84bea85

Please sign in to comment.