~rjarry/aerc-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
4 3

[PATCH aerc] config: add option for SMTP HELO/EHLO local domain

Details
Message ID
<20230129221631.48877-1-kdk@freeshell.de>
DKIM signature
missing
Download raw message
Patch: +22 -2
Expose go-smtp functionality for setting the domain name as a config
option. This allows aerc to communicate with SMTP servers with strict
antispam measures without relying on sendmail.

In theory, this should be set to a fully qualified domain name, but some
servers simply forbid the use of "localhost", so it is reasonable to let
the user set whatever value works for them.

For comparison, this is equivalent to the functionality of the "domain"
option of msmtp.

Signed-off-by: Karel D. Kopecký <kdk@freeshell.de>
---
 CHANGELOG.md             |  2 ++
 commands/compose/send.go | 16 ++++++++++++++--
 doc/aerc-smtp.5.scd      |  6 ++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 53c1dcb..450465e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add a `msglist_answered` style for answered messages.
- Compose `Format=Flowed` messages with `format-flowed=true` in `aerc.conf`.
- Add a `trimSignature` function to the templating engine.
- Change local domain name for SMTP with `smtp-domain=example.com` in
  `aerc.conf`

### Changed

diff --git a/commands/compose/send.go b/commands/compose/send.go
index 4029552..1b65ab0 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -93,6 +93,10 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
	if starttls_, ok := config.Params["smtp-starttls"]; ok {
		starttls = starttls_ == "yes"
	}
	var domain string
	if domain_, ok := config.Params["smtp-domain"]; ok {
		domain = domain_
	}
	ctx := sendCtx{
		uri:      uri,
		scheme:   scheme,
@@ -100,6 +104,7 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
		starttls: starttls,
		from:     config.From,
		rcpts:    rcpts,
		domain:   domain,
	}

	warn, err := composer.ShouldWarnAttachment()
@@ -236,6 +241,7 @@ type sendCtx struct {
	starttls bool
	from     *mail.Address
	rcpts    []*mail.Address
	domain   string
}

func newSendmailSender(ctx sendCtx) (io.WriteCloser, error) {
@@ -393,7 +399,7 @@ func newSmtpSender(ctx sendCtx) (io.WriteCloser, error) {
	)
	switch ctx.scheme {
	case "smtp":
		conn, err = connectSmtp(ctx.starttls, ctx.uri.Host)
		conn, err = connectSmtp(ctx.starttls, ctx.uri.Host, ctx.domain)
	case "smtps":
		conn, err = connectSmtps(ctx.uri.Host)
	default:
@@ -437,7 +443,7 @@ func newSmtpSender(ctx sendCtx) (io.WriteCloser, error) {
	return s.w, nil
}

func connectSmtp(starttls bool, host string) (*smtp.Client, error) {
func connectSmtp(starttls bool, host string, domain string) (*smtp.Client, error) {
	serverName := host
	if !strings.ContainsRune(host, ':') {
		host += ":587" // Default to submission port
@@ -448,6 +454,12 @@ func connectSmtp(starttls bool, host string) (*smtp.Client, error) {
	if err != nil {
		return nil, errors.Wrap(err, "smtp.Dial")
	}
	if domain != "" {
		err := conn.Hello(domain)
		if err != nil {
			return nil, errors.Wrap(err, "Hello")
		}
	}
	if sup, _ := conn.Extension("STARTTLS"); sup {
		if !starttls {
			err := errors.New("STARTTLS is supported by this server, " +
diff --git a/doc/aerc-smtp.5.scd b/doc/aerc-smtp.5.scd
index 7583715..850a71b 100644
--- a/doc/aerc-smtp.5.scd
+++ b/doc/aerc-smtp.5.scd
@@ -64,6 +64,12 @@ are available:

	Default: _false_

*smtp-domain* = _<domain>_
	Local domain name to use in the HELO/EHLO SMTP command. Set this to a fully
	qualified domain name if the server requires it as an antispam measure.

	Default: _localhost_

# SEE ALSO

*aerc*(1) *aerc-accounts*(5)
-- 
2.39.1

[aerc/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CQ50VSPYQJ4N.3429IFKZ64BU@cirno2>
In-Reply-To
<20230129221631.48877-1-kdk@freeshell.de> (view parent)
DKIM signature
missing
Download raw message
aerc/patches: SUCCESS in 4m1s

[config: add option for SMTP HELO/EHLO local domain][0] from [Karel D. Kopecký][1]

[0]: https://lists.sr.ht/~rjarry/aerc-devel/patches/38534
[1]: kdk@freeshell.de

✓ #930806 SUCCESS aerc/patches/openbsd.yml     https://builds.sr.ht/~rjarry/job/930806
✓ #930805 SUCCESS aerc/patches/alpine-edge.yml https://builds.sr.ht/~rjarry/job/930805
Details
Message ID
<CQ7LVI73SNJ6.U4TPAX6D6NEK@ringo>
In-Reply-To
<20230129221631.48877-1-kdk@freeshell.de> (view parent)
DKIM signature
missing
Download raw message
Karel D. Kopecký, Jan 29, 2023 at 23:16:
> Expose go-smtp functionality for setting the domain name as a config
> option. This allows aerc to communicate with SMTP servers with strict
> antispam measures without relying on sendmail.
>
> In theory, this should be set to a fully qualified domain name, but some
> servers simply forbid the use of "localhost", so it is reasonable to let
> the user set whatever value works for them.
>
> For comparison, this is equivalent to the functionality of the "domain"
> option of msmtp.
>
> Signed-off-by: Karel D. Kopecký <kdk@freeshell.de>

Looks good to me :)

Acked-by: Robin Jarry <robin@jarry.cc>
Details
Message ID
<CQ8GLMYD7J7Q.1RF64E0NGYMXO@ringo>
In-Reply-To
<20230129221631.48877-1-kdk@freeshell.de> (view parent)
DKIM signature
missing
Download raw message
Karel D. Kopecký, Jan 29, 2023 at 23:16:
> Expose go-smtp functionality for setting the domain name as a config
> option. This allows aerc to communicate with SMTP servers with strict
> antispam measures without relying on sendmail.
>
> In theory, this should be set to a fully qualified domain name, but some
> servers simply forbid the use of "localhost", so it is reasonable to let
> the user set whatever value works for them.
>
> For comparison, this is equivalent to the functionality of the "domain"
> option of msmtp.
>
> Signed-off-by: Karel D. Kopecký <kdk@freeshell.de>
> ---

Acked-by: Robin-Jarry <robin@jarry.cc>

Applied. Thanks!
Details
Message ID
<CQ8QKN1R39H0.3S9JIIAAY57VF@konata>
In-Reply-To
<CQ8GLMYD7J7Q.1RF64E0NGYMXO@ringo> (view parent)
DKIM signature
missing
Download raw message
On Fri Feb 3, 2023 at 12:17 AM CET, Robin Jarry wrote:
> Karel D. Kopecký, Jan 29, 2023 at 23:16:
> > Expose go-smtp functionality for setting the domain name as a config
> > option. This allows aerc to communicate with SMTP servers with strict
> > antispam measures without relying on sendmail.
> >
> > In theory, this should be set to a fully qualified domain name, but some
> > servers simply forbid the use of "localhost", so it is reasonable to let
> > the user set whatever value works for them.
> >
> > For comparison, this is equivalent to the functionality of the "domain"
> > option of msmtp.
> >
> > Signed-off-by: Karel D. Kopecký <kdk@freeshell.de>
> > ---
>
> Acked-by: Robin-Jarry <robin@jarry.cc>
>
> Applied. Thanks!
Reply to thread Export thread (mbox)