Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions email.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func sendResendEmail(to, _, _ []string, from, subject, body string, attachments

request := &resend.SendEmailRequest{
From: from,
ReplyTo: replyTo,
To: to,
Subject: subject,
Cc: cc,
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const ResendAPIKey = "RESEND_API_KEY" //nolint:gosec
// PopFrom is the environment variable that sets the default "from" address.
const PopFrom = "POP_FROM"

// PopReplyTo is the environment variable that sets the default reply-to address.
const PopReplyTo = "POP_REPLY_TO"

// PopSignature is the environment variable that sets the default signature.
const PopSignature = "POP_SIGNATURE"

Expand All @@ -51,6 +54,7 @@ const PopSMTPInsecureSkipVerify = "POP_SMTP_INSECURE_SKIP_VERIFY"

var (
from string
replyTo string
to []string
cc []string
bcc []string
Expand Down Expand Up @@ -137,6 +141,7 @@ var rootCmd = &cobra.Command{

p := tea.NewProgram(NewModel(resend.SendEmailRequest{
From: from,
ReplyTo: replyTo,
To: to,
Bcc: bcc,
Cc: cc,
Expand Down Expand Up @@ -203,6 +208,8 @@ func init() {
rootCmd.Flags().StringVarP(&body, "body", "b", "", "Email's contents")
envFrom := os.Getenv(PopFrom)
rootCmd.Flags().StringVarP(&from, "from", "f", envFrom, "Email's sender"+commentStyle.Render("($"+PopFrom+")"))
envReplyTo := os.Getenv(PopReplyTo)
rootCmd.Flags().StringVarP(&replyTo, "reply-to", "R", envReplyTo, "Email's reply-to address"+commentStyle.Render("($"+PopReplyTo+")"))
rootCmd.Flags().StringVarP(&subject, "subject", "s", "", "Email's subject")
rootCmd.Flags().BoolVar(&preview, "preview", false, "Whether to preview the email before sending")
envUnsafe := os.Getenv(PopUnsafeHTML) == "true"
Expand Down
15 changes: 15 additions & 0 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type Model struct {

// From represents the sender's email address.
From textinput.Model
// ReplyTo represents the reply-to email address.
ReplyTo textinput.Model
// To represents the recipient's email address.
// This can be a comma-separated list of addresses.
To textinput.Model
Expand Down Expand Up @@ -96,6 +98,16 @@ func NewModel(defaults resend.SendEmailRequest, deliveryMethod DeliveryMethod) M
from.PlaceholderStyle = placeholderStyle
from.SetValue(defaults.From)

replyTo := textinput.New()
replyTo.Prompt = "Reply-To "
replyTo.Placeholder = "[email protected]"
replyTo.PromptStyle = labelStyle.Copy()
replyTo.PromptStyle = labelStyle
replyTo.TextStyle = textStyle
replyTo.Cursor.Style = cursorStyle
replyTo.PlaceholderStyle = placeholderStyle
replyTo.SetValue(defaults.ReplyTo)

to := textinput.New()
to.Prompt = "To "
to.PromptStyle = labelStyle.Copy()
Expand Down Expand Up @@ -192,6 +204,7 @@ func NewModel(defaults resend.SendEmailRequest, deliveryMethod DeliveryMethod) M
m := Model{
state: state,
From: from,
ReplyTo: replyTo,
To: to,
showCc: len(cc.Value()) > 0 || len(bcc.Value()) > 0,
Cc: cc,
Expand Down Expand Up @@ -440,6 +453,8 @@ func (m Model) View() string {

s.WriteString(m.From.View())
s.WriteString("\n")
s.WriteString(m.ReplyTo.View())
s.WriteString("\n")
s.WriteString(m.To.View())
s.WriteString("\n")
if m.showCc {
Expand Down