#!/bin/bash
# email - email message support

set -e


######
# Config

net_email_config_init() {
	:
}

net_email_config_check() {
	:
}


######
# header functions

email_headers() {
	has_args 1 "$@"
	local file=$1
	sed -n '/^$/q;p' $file
}

email_headers_simple() {
	email_headers "$1" | grep -iEe "^(to|from|subject|date): "
}

email_header() {
	local file=$1
	local name=$2
	email_headers "$file" | grep -i "^$name: "
}

email_header_values() {
	email_header "$@" | sed 's,[^:]*: ,,'
}


######
# body functions

email_body() {
	has_args 1 "$@"
	local file=$1
	sed -n '/^$/,$p' $file | tail -n +2
}

email_content() {
	has_args 1 "$@"
	email_body "$1" | sed '/^-- $/,$d'
}


######
# display

email_view() {
	has_args 1 "$@"
	local file=$1
	local tmp
	tmp=$(cmd_tempfile)
	email_headers_simple "$file" >"$tmp"
	email_body "$file" >>"$tmp"
	run_pager "$tmp"
}

View the Developer Guide Index

View the Reference Manual Index


Generated on Fri Jul 28 14:35:47 PDT 2017 by mcsh d14 v0.23.0.