-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend
More file actions
executable file
·46 lines (37 loc) · 1.54 KB
/
send
File metadata and controls
executable file
·46 lines (37 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
## ISSUES
# Combine all config files in one unified config file: .smtp
# Replace /etc/smtp/ with /etc/smtp.config
# Check $HOME/.smtp as well in case ser has no sudo privileges
# Look for /bin/pop OR $HOME/bin/pop
# Send an email using Charmbracelet's POP
# Config store in /etc/smtp/{host,user,pass,from}
set -e
time=$(TZ=America/Toronto date)
command -v pop > /dev/null || { echo "POP NOT FOUND: install with go install github.com/charmbracelet/pop@latest" >&2; exit 1; }
[[ -n "$to" ]] || { echo "send: 'to' is required: to=RECIPIENT send MESSAGE" >&2; exit 1; }
[[ -n "$1" ]] || { echo "send: message body required" >&2; exit 1; }
[[ -n "$sub" ]] || sub="Message from $HOSTNAME, $USER ($(uname -sr)) on $time"
POP_SMTP_HOST=$(cat /etc/smtp/host) \
POP_SMTP_PORT=587 \
POP_SMTP_USERNAME=$(cat /etc/smtp/user) \
POP_SMTP_PASSWORD=$(cat /etc/smtp/pass) \
/bin/pop \
-f "$(cat /etc/smtp/from)" \
-t "$to" \
-s "$sub" \
-b "$*" \
>> /tmp/send.log
# Usage:
# pop [flags]
# pop [command]
#Flags:
# -a, --attach strings Email's attachments
# --bcc strings BCC recipients
# -b, --body string Email's contents
# --cc strings CC recipients
# -h, --help help for pop
# -x, --signature string Signature to display at the end of the email. ($POP_SIGNATURE)
# -e, --smtp.encryption string Encryption type of the SMTP server (starttls, ssl, or none) ($POP_SMTP_ENCRYPTION)
# -s, --subject string Email's subject
# -t, --to strings Recipients