Categorygithub.com/modfin/brev
modulepackage
0.0.0-20240501114741-f83f88ea00da
Repository: https://github.com/modfin/brev.git
Documentation: pkg.go.dev

# README

Brev

A cli that send email directly to the mx servers of the world

Install

go get github.com/modfin/brev/cmd/brev
go get github.com/modfin/brev/cmd/brevd

Brevd Usage

The Brevd is server for transactional emails via http api.

Configure

  • Choose a host domain you are going to use for the brevd server, eg. brev.cc
  • Choose a client domain from which to send emails, eg. example.com
  • Find out what ip you are running the service on, eg 1.2.3.4
  • Generate a dkim key-pair, eg brev gen-dkim-keys --key-size=2048. This generates two files. dkim-private.pem is loaded into brevd and dkim-pub.dns.txt which is put into a TXT record on the client domain

Host DNS Config

Add a A record for your server, eg mx0.brev.cc pointing to the ip, 1.2.3.4
Should result in the following

dig A mx0.brev.cc

;; ANSWER SECTION:
mx0.brev.cc.            260     IN      A       1.2.3.4

Add a MX record for your server to for your domain, eg brev.cc pointing to the brevd server
Should result in the following

dig MX brev.cc
 
;; ANSWER SECTION:
brev.cc.                300     IN      MX      10 mx0.brev.cc.

Add a SPF policy through TXT record for your domain, eg brev.cc pointing to you brevd server, eg v=spf1 mx -all
Should result in the following

dig TXT brev.cc 
brev.cc.                300     IN      TXT     "v=spf1 mx -all"

Finally, set up PTR records through your ISP, eg 1.2.3.4 -> mx0.brev.cc

Client DNS Config

Say you now want send your emails and have them come from [email protected]

Add a SPF policy to example.com through TXT record pointing to the brev.cc domain, eg v=spf1 include:brev.cc -all
Should result in the following

dig TXT example.com
 
;; ANSWER SECTION:
example.com.              60      IN      TXT     "v=spf1 include:brev.cc -all"

Add a DKIM public key to example.com by choosing a selector, eg brev and adding the public key to TXT record at brev._domainkey.example.com
Should result in the following

dig TXT brev._domainkey.example.com

;; ANSWER SECTION:
brev._domainkey.example.com. 300  IN      TXT     "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A....;"

Server config

Create a run script that configures the environment for you

cat ./run-brevd.sh
export BREV_HOSTNAME=mx0.brev.cc
export BREV_DB_URI=$(pwd)/brev.sqlite

export BREV_MX_DOMAIN=brev.cc
export BREV_MX_PORT=25

export BREV_DKIM_SELECTOR=brev
export BREV_DKIM_PRIVATE_KEY=./path/to/dkim-private.pem
brevd

Brev Usage

The Brev cli is a small utility to send emails directly to a MX server

NAME:
   brev - a cli that send email directly to the mx servers

USAGE:
   brev [global options] command [command options] [arguments...]

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --subject value     Set subject line
   --from value        Set from email
   --message-id value  set the message id
   --to value          Set to email
   --cc value          Set cc email
   --bcc value         Set cc email
   --text value        text content of the mail
   --html value        html content of the mail
   --attach value      path to file attachment
   --help, -h          show help (default: false)

Example

brev --subject="An attachment" \
        --to="[email protected]" \
        --cc="[email protected]" \
        --cc="[email protected]" \
        --attach="/path/to/a.file" \
        --text='The body of the email' 

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

New returns a new brev client that can be used to send emails across multiple brev servers apiKey is the key used to gain access to the servers, domain is the domain which the emails will be sent from posthookUrl will receive posts with information regarding the status of the sent email target servers are the different brev servers that the client will use to send emails if we are unable to send an email, maxRetries determines how many extra times we attempt to send the email.
No description provided by the author

# Constants

EventBounce Receiving server could not or would not accept message.
EventDeferred Recipient's email server temporarily rejected message.
EventDelivered Message has been successfully delivered to the receiving server.
EventDropped the message was dropped by brev.
EventFailed for some reason, sending the email failed.
EventSpam Recipient marked a message as spam.
EventUnsubscribe Recipient clicked on message's subscription management link.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author