I’ve created a simple script in Bash which can send e-mails with attachment through commandline. You need “mutt” and a working mail system in order to get this working. You need to create a textfile named mailmessage.txt in your home map that includes the text of the mail.


ONDERWERP="With an important attachment"
echo "What's the e-mail of the recipient"
echo "Locate the attachment:"
mutt -s $ONDERWERP -a $ATTACHMENT $EMAILADRES < /home/$USER/mailmessage.txt

I'm using postfix as Mail Tranfer agent. You will notice I'm using Telenet as a relayhost. This is my /etc/postfix/main.cf

smtpd_banner = $myhostname ESMTP $mail_name (Postfix & GNU/Linux up and running)
biff = no.
append_dot_mydomain = no
# TLS parameters
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

myhostname = ubuntux
mydomain = phar0zlinux.net
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = phar0zlinux.net, localhost, localhost.phar0zlinux.net, localhost
relayhost = uit.telenet.be
mynetworks =, 192.168.0.*,
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
myorigin = localhost
inet_protocols = all
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_tls_auth_only = no
smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
home_mailbox = Maildir/