b3c22c261e
Add explicit TLS modes, context-aware delivery, and typed transport errors. Preserve raw MIME messages and cover the new delivery paths with local SMTP tests.
27 lines
671 B
Go
27 lines
671 B
Go
package email
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type MockCallbackFn func(params ...interface{})
|
|
|
|
// NewMockMailService is retained for compatibility. It never creates a network
|
|
// connection and contains no insecure TLS configuration.
|
|
func NewMockMailService(callbackFn MockCallbackFn, params ...interface{}) *EmailService {
|
|
return &EmailService{
|
|
from: "mock@example.invalid",
|
|
connectTimeout: DefaultConnectTimeout,
|
|
operationTimeout: DefaultOperationTimeout,
|
|
sendRawHook: func(ctx context.Context, _ RawMessage) error {
|
|
if err := ctx.Err(); err != nil {
|
|
return err
|
|
}
|
|
if callbackFn != nil {
|
|
callbackFn(params...)
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
}
|