Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update sendEmailCLI.sh to support sending attachments (#151)
Leendert de Borstea4d49850211
diff --git a/src/Services/AliasVault.SmtpService/Scripts/sendEmailCLI.sh b/src/Services/AliasVault.SmtpService/Scripts/sendEmailCLI.shindex d807c8fc1..1c1fcac36 100755--- a/src/Services/AliasVault.SmtpService/Scripts/sendEmailCLI.sh+++ b/src/Services/AliasVault.SmtpService/Scripts/sendEmailCLI.sh@@ -1,7 +1,13 @@#!/bin/bashgenerate_random_string() {- cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-10} | head -n 1+ LC_ALL=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w ${1:-10} | head -n 1+}++generate_random_attachment() {+ local temp_file="/tmp/test_attachment_$(generate_random_string 8).txt"+ echo "This is a test attachment content - $(generate_random_string 32)" > "$temp_file"+ echo "$temp_file"}print_logo() {@@ -23,25 +29,54 @@ print_logo() {send_email() {local recipient="$1"+ local with_attachment="$2"local subject_suffix=$(generate_random_string 8)local content_suffix=$(generate_random_string 20)+ local boundary="boundary-$(generate_random_string 16)"+ local attachment_content="This is a test attachment content - $(generate_random_string 32)"+ local attachment_name="test_attachment_$(generate_random_string 8).txt"- cat > temp_email.txt << EOF-From: [email protected]-To: $recipient-Subject: Test Email - $subject_suffix--This is a test email.--Random content: $content_suffix-EOF-- curl --url "smtp://localhost:25" \- --mail-from "[email protected]" \- --mail-rcpt "$recipient" \- --upload-file temp_email.txt-- rm temp_email.txt+ if [[ "$with_attachment" =~ ^[Yy]$ ]]; then+ {+ echo "From: [email protected]"+ echo "To: $recipient"+ echo "Subject: Test Email with Attachment - $subject_suffix"+ echo "MIME-Version: 1.0"+ echo "Content-Type: multipart/mixed; boundary=$boundary"+ echo ""+ echo "--$boundary"+ echo "Content-Type: text/plain; charset=utf-8"+ echo ""+ echo "This is a test email with attachment."+ echo ""+ echo "Random content: $content_suffix"+ echo ""+ echo "--$boundary"+ echo "Content-Type: application/octet-stream"+ echo "Content-Transfer-Encoding: base64"+ echo "Content-Disposition: attachment; filename=\"$attachment_name\""+ echo ""+ echo "$attachment_content" | base64+ echo ""+ echo "--$boundary--"+ } | curl --url "smtp://localhost:25" \+ --mail-from "[email protected]" \+ --mail-rcpt "$recipient" \+ --upload-file -+ else+ {+ echo "From: [email protected]"+ echo "To: $recipient"+ echo "Subject: Test Email - $subject_suffix"+ echo ""+ echo "This is a test email."+ echo ""+ echo "Random content: $content_suffix"+ } | curl --url "smtp://localhost:25" \+ --mail-from "[email protected]" \+ --mail-rcpt "$recipient" \+ --upload-file -+ fi}print_logo@@ -49,19 +84,18 @@ print_logowhile true; doif [[ -z "$recipient" ]]; thenread -p "Enter the recipient's email address: " recipient+ read -p "Do you want to send emails with attachments? (y/N): " with_attachmentfi- send_email "$recipient"+ send_email "$recipient" "$with_attachment"- read -p "Send another email? (Press Enter for same recipient, or type a new email, or 'q' to quit): " next_action+ read -p "Send another email? (Press Enter for same recipient/settings, or type a new email, or 'q' to quit): " next_actionif [[ "$next_action" == "q" ]]; thenecho "Exiting the script. Goodbye!"exit 0elif [[ -n "$next_action" ]]; thenrecipient="$next_action"- else- # If next_action is empty (user pressed Enter), keep the same recipient- :+ read -p "Do you want to send emails with attachments? (y/N): " with_attachmentfidone