Skip to content
This repository was archived by the owner on Feb 24, 2024. It is now read-only.

Commit 95c2e1a

Browse files
committed
move gomail into interal because of go-mail/mail#39
1 parent 04da9bd commit 95c2e1a

18 files changed

+1493
-3
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ require (
4848
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f
4949
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8 // indirect
5050
golang.org/x/tools v0.0.0-20181111003725-6d71ab8aade0
51-
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
51+
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc
5252
)

go.sum

-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
429429
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
430430
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
431431
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo=
432-
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
433432
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
434433
gopkg.in/mail.v2 v2.0.0-20180731213649-a0242b2233b4/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw=
435434
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=

mail/internal/mail/.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
3+
# Binaries for programs and plugins
4+
*.exe
5+
*.dll
6+
*.so
7+
*.dylib
8+
9+
# Test binary, build with `go test -c`
10+
*.test
11+
12+
# Output of the go coverage tool, specifically when used with LiteIDE
13+
*.out
14+
15+
16+
# IDE's
17+
.idea/

mail/internal/mail/.travis.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: go
2+
3+
go:
4+
- 1.2
5+
- 1.3
6+
- 1.4
7+
- 1.5
8+
- 1.6
9+
- 1.7
10+
- 1.8
11+
- 1.9
12+
- master
13+
14+
# safelist
15+
branches:
16+
only:
17+
- master
18+
- v2
19+
20+
notifications:
21+
email: false
22+
23+
before_install:
24+
- mkdir -p $GOPATH/src/gopkg.in &&
25+
ln -s ../github.com/go-mail/mail $GOPATH/src/gopkg.in/mail.v2

mail/internal/mail/CHANGELOG.md

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Change Log
2+
All notable changes to this project will be documented in this file.
3+
This project adheres to [Semantic Versioning](http://semver.org/).
4+
5+
## *Unreleased*
6+
7+
## [2.3.0] - 2018-11-10
8+
9+
### Added
10+
11+
- #12: Adds `SendError` to provide additional info about the cause and index of
12+
a failed attempt to transmit a batch of messages.
13+
- go-gomail#78: Adds new `Message` methods for attaching and embedding
14+
`io.Reader`s: `AttachReader` and `EmbedReader`.
15+
- #39: Adds support for Go modules (Go 1.11+).
16+
17+
### Fixed
18+
19+
- #26: Fixes RFC 1341 compliance by properly capitalizing the
20+
`MIME-Version` header.
21+
- #30: Fixes IO errors being silently dropped in `Message.WriteTo`.
22+
23+
## [2.2.0] - 2018-03-01
24+
25+
### Added
26+
27+
- #20: Adds `Message.SetBoundary` to allow specifying a custom MIME boundary.
28+
- #22: Adds `Message.SetBodyWriter` to make it easy to use text/template and
29+
html/template for message bodies. Contributed by Quantcast.
30+
- #25: Adds `Dialer.StartTLSPolicy` so that `MandatoryStartTLS` can be required,
31+
or `NoStartTLS` can disable it. Contributed by Quantcast.
32+
33+
## [2.1.0] - 2017-12-14
34+
35+
### Added
36+
37+
- go-gomail#40: Adds `Dialer.LocalName` field to allow specifying the hostname
38+
sent with SMTP's HELO command.
39+
- go-gomail#47: `Message.SetBody`, `Message.AddAlternative`, and
40+
`Message.AddAlternativeWriter` allow specifying the encoding of message parts.
41+
- `Dialer.Dial`'s returned `SendCloser` automatically redials after a timeout.
42+
- go-gomail#55, go-gomail#56: Adds `Rename` to allow specifying filename
43+
of an attachment.
44+
- go-gomail#100: Exports `NetDialTimeout` to allow setting a custom dialer.
45+
- go-gomail#70: Adds `Dialer.Timeout` field to allow specifying a timeout for
46+
dials, reads, and writes.
47+
48+
### Changed
49+
50+
- go-gomail#52: `Dialer.Dial` automatically uses CRAM-MD5 when available.
51+
- `Dialer.Dial` specifies a default timeout of 10 seconds.
52+
- Gomail is forked from <https://github.com/go-gomail/gomail/> to
53+
<https://github.com/go-mail/mail/>.
54+
55+
### Deprecated
56+
57+
- go-gomail#52: `NewPlainDialer` is deprecated in favor of `NewDialer`.
58+
59+
### Fixed
60+
61+
- go-gomail#41, go-gomail#42: Fixes a panic when a `Message` contains a
62+
nil header.
63+
- go-gomail#44: Fixes `AddAlternativeWriter` replacing the message body instead
64+
of adding a body part.
65+
- go-gomail#53: Folds long header lines for RFC 2047 compliance.
66+
- go-gomail#54: Fixes `Message.FormatAddress` when name is blank.
67+
68+
## [2.0.0] - 2015-09-02
69+
70+
- Mailer has been removed. It has been replaced by Dialer and Sender.
71+
- `File` type and the `CreateFile` and `OpenFile` functions have been removed.
72+
- `Message.Attach` and `Message.Embed` have a new signature.
73+
- `Message.GetBodyWriter` has been removed. Use `Message.AddAlternativeWriter`
74+
instead.
75+
- `Message.Export` has been removed. `Message.WriteTo` can be used instead.
76+
- `Message.DelHeader` has been removed.
77+
- The `Bcc` header field is no longer sent. It is far more simpler and
78+
efficient: the same message is sent to all recipients instead of sending a
79+
different email to each Bcc address.
80+
- LoginAuth has been removed. `NewPlainDialer` now implements the LOGIN
81+
authentication mechanism when needed.
82+
- Go 1.2 is now required instead of Go 1.3. No external dependency are used when
83+
using Go 1.5.

mail/internal/mail/CONTRIBUTING.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Thank you for contributing to Gomail! Here are a few guidelines:
2+
3+
## Bugs
4+
5+
If you think you found a bug, create an issue and supply the minimum amount
6+
of code triggering the bug so it can be reproduced.
7+
8+
9+
## Fixing a bug
10+
11+
If you want to fix a bug, you can send a pull request. It should contains a
12+
new test or update an existing one to cover that bug.
13+
14+
15+
## New feature proposal
16+
17+
If you think Gomail lacks a feature, you can open an issue or send a pull
18+
request. I want to keep Gomail code and API as simple as possible so please
19+
describe your needs so we can discuss whether this feature should be added to
20+
Gomail or not.

mail/internal/mail/LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Alexandre Cesaro
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

mail/internal/mail/README.md

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Gomail
2+
[![Build Status](https://travis-ci.org/go-mail/mail.svg?branch=master)](https://travis-ci.org/go-mail/mail) [![Code Coverage](http://gocover.io/_badge/github.com/go-mail/mail)](http://gocover.io/github.com/go-mail/mail) [![Documentation](https://godoc.org/github.com/go-mail/mail?status.svg)](https://godoc.org/github.com/go-mail/mail)
3+
4+
This is an actively maintained fork of [Gomail][1] and includes fixes and
5+
improvements for a number of outstanding issues. The current progress is
6+
as follows:
7+
8+
- [x] Timeouts and retries can be specified outside of the 10 second default.
9+
- [x] Proxying is supported through specifying a custom [NetDialTimeout][2].
10+
- [ ] Filenames are properly encoded for non-ASCII characters.
11+
- [ ] Email addresses are properly encoded for non-ASCII characters.
12+
- [ ] Embedded files and attachments are tested for their existence.
13+
- [ ] An `io.Reader` can be supplied when embedding and attaching files.
14+
15+
See [Transitioning Existing Codebases][3] for more information on switching.
16+
17+
[1]: https://github.com/go-gomail/gomail
18+
[2]: https://godoc.org/gopkg.in/mail.v2#NetDialTimeout
19+
[3]: #transitioning-existing-codebases
20+
21+
## Introduction
22+
23+
Gomail is a simple and efficient package to send emails. It is well tested and
24+
documented.
25+
26+
Gomail can only send emails using an SMTP server. But the API is flexible and it
27+
is easy to implement other methods for sending emails using a local Postfix, an
28+
API, etc.
29+
30+
It requires Go 1.2 or newer. With Go 1.5, no external dependencies are used.
31+
32+
33+
## Features
34+
35+
Gomail supports:
36+
- Attachments
37+
- Embedded images
38+
- HTML and text templates
39+
- Automatic encoding of special characters
40+
- SSL and TLS
41+
- Sending multiple emails with the same SMTP connection
42+
43+
44+
## Documentation
45+
46+
https://godoc.org/github.com/go-mail/mail
47+
48+
49+
## Download
50+
51+
If you're already using a dependency manager, like [dep][dep], use the following
52+
import path:
53+
54+
```
55+
github.com/go-mail/mail
56+
```
57+
58+
If you *aren't* using vendoring, `go get` the [Gopkg.in](http://gopkg.in)
59+
import path:
60+
61+
```
62+
gopkg.in/mail.v2
63+
```
64+
65+
[dep]: https://github.com/golang/dep#readme
66+
67+
## Examples
68+
69+
See the [examples in the documentation](https://godoc.org/github.com/go-mail/mail#example-package).
70+
71+
72+
## FAQ
73+
74+
### x509: certificate signed by unknown authority
75+
76+
If you get this error it means the certificate used by the SMTP server is not
77+
considered valid by the client running Gomail. As a quick workaround you can
78+
bypass the verification of the server's certificate chain and host name by using
79+
`SetTLSConfig`:
80+
81+
```go
82+
package main
83+
84+
import (
85+
"crypto/tls"
86+
87+
"gopkg.in/mail.v2"
88+
)
89+
90+
func main() {
91+
d := mail.NewDialer("smtp.example.com", 587, "user", "123456")
92+
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
93+
94+
// Send emails using d.
95+
}
96+
```
97+
98+
Note, however, that this is insecure and should not be used in production.
99+
100+
### Transitioning Existing Codebases
101+
102+
If you're already using the original Gomail, switching is as easy as updating
103+
the import line to:
104+
105+
```
106+
import gomail "gopkg.in/mail.v2"
107+
```
108+
109+
## Contribute
110+
111+
Contributions are more than welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for
112+
more info.
113+
114+
115+
## Change log
116+
117+
See [CHANGELOG.md](CHANGELOG.md).
118+
119+
120+
## License
121+
122+
[MIT](LICENSE)
123+
124+
125+
## Support & Contact
126+
127+
You can ask questions on the [Gomail
128+
thread](https://groups.google.com/d/topic/golang-nuts/jMxZHzvvEVg/discussion)
129+
in the Go mailing-list.

mail/internal/mail/auth.go

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package mail
2+
3+
import (
4+
"bytes"
5+
"errors"
6+
"fmt"
7+
"net/smtp"
8+
)
9+
10+
// loginAuth is an smtp.Auth that implements the LOGIN authentication mechanism.
11+
type loginAuth struct {
12+
username string
13+
password string
14+
host string
15+
}
16+
17+
func (a *loginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
18+
if !server.TLS {
19+
advertised := false
20+
for _, mechanism := range server.Auth {
21+
if mechanism == "LOGIN" {
22+
advertised = true
23+
break
24+
}
25+
}
26+
if !advertised {
27+
return "", nil, errors.New("gomail: unencrypted connection")
28+
}
29+
}
30+
if server.Name != a.host {
31+
return "", nil, errors.New("gomail: wrong host name")
32+
}
33+
return "LOGIN", nil, nil
34+
}
35+
36+
func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) {
37+
if !more {
38+
return nil, nil
39+
}
40+
41+
switch {
42+
case bytes.Equal(fromServer, []byte("Username:")):
43+
return []byte(a.username), nil
44+
case bytes.Equal(fromServer, []byte("Password:")):
45+
return []byte(a.password), nil
46+
default:
47+
return nil, fmt.Errorf("gomail: unexpected server challenge: %s", fromServer)
48+
}
49+
}

mail/internal/mail/doc.go

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Package gomail provides a simple interface to compose emails and to mail them
2+
// efficiently.
3+
//
4+
// More info on Github: https://github.com/go-mail/mail
5+
//
6+
package mail

mail/internal/mail/errors.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package mail
2+
3+
import "fmt"
4+
5+
// A SendError represents the failure to transmit a Message, detailing the cause
6+
// of the failure and index of the Message within a batch.
7+
type SendError struct {
8+
// Index specifies the index of the Message within a batch.
9+
Index uint
10+
Cause error
11+
}
12+
13+
func (err *SendError) Error() string {
14+
return fmt.Sprintf("gomail: could not send email %d: %v",
15+
err.Index+1, err.Cause)
16+
}

0 commit comments

Comments
 (0)