if you want to send mail from a client not from a server – you will need:
- some client software
- valid account on an external mail server
warning! Sendemail is unable to accept self-signed SSL certificates… so you will need to authenticate with your mail-server in plain-text port 25 – this is not optimal
apt-cache search smtp|grep client; # search for mail client software on debian sendemail - lightweight, command line SMTP email client <- sounds interesting libnet-smtp-tls-butmaintained-perl - Perl module for providing SMTP client supporting TLS and AUTH libnet-smtp-tls-perl - Perl SMTP client library supporting TLS and AUTH msmtp - light SMTP client with support for server profiles <- sounds interesting msmtp-gnome - light SMTP client with support for server profiles - with GNOME keyring support msmtp-mta - light SMTP client with support for server profiles - the regular MTA nsca-client - Nagios service monitor agent - client package alpine - Text-based email client, friendly for novices but powerful alpine-dbg - Text-based email client's debugging symbols automx - Provides account configuration data to mailclients balsa - e-mail client for GNOME balsa-dbg - e-mail client for GNOME - debugging symbols libcurl3 - easy-to-use client-side URL transfer library (OpenSSL flavour) libcurl3-gnutls - easy-to-use client-side URL transfer library (GnuTLS flavour) libcurl3-nss - easy-to-use client-side URL transfer library (NSS flavour) cyrus-clients - Cyrus mail system - test clients gnunet-fuse - secure, trust-based peer-to-peer framework (fuse filesystem client) gnunet-gtk - secure, trust-based peer-to-peer framework (GTK+ client) gnunet-gtk-dbg - secure, trust-based peer-to-peer framework (GTK+ client debug) gnunet-gtk-dev - secure, trust-based peer-to-peer framework (GTK+ client development) libghc-smtpclient-dev - Simple Haskell SMTP client library libghc-smtpclient-doc - Simple Haskell SMTP client library; documentation libghc-smtpclient-prof - Simple Haskell SMTP client library; profiling libraries ilohamail - Light weight yet full featured multilingual web-based IMAP/POP3 client libesmtp-dev - LibESMTP SMTP client library (development files) libesmtp6 - LibESMTP SMTP client library srs - command-line Sender Rewriting Scheme client
sendemail – setup config install and example
# install sendemail lightweight, command line SMTP email client apt-get update && apt-get -y install sendemail echo "" > /var/log/exim4/mainlog; # reset mail log tail -f /var/log/exim4/mainlog & # give immediate output of things that are going on vim /scripts/sendemail.sh; # new test script for sending mail via external mail server, fill in those lines #!/bin/bash # send mails via external-mail-server that supports smpt-authentication via password # behind -xu needs to be the username that is used to smpt-login to the server, in this case it is equal to sender's mail address, but does not necessarily need to be the same! sendemail -o tls=no -s external-mail-sever.com -f email@example.com -t firstname.lastname@example.org -u "TEST" -xu email@example.com -xp "Top_Secret-Password!" -m "this is the message-body-text" -a /path/to/attachment.tar.gz ESC :x # save file and quit vim chmod u+x /scripts/sendemail.sh; # mark it runnable /scripts/sendemail.sh; # give it a try # you should get something like: May 22 11:38:04 debian sendemail: Email was sent successfully!
Worked perfectly! Thanks 🙂 creditz:
Report bugs to <http://bugs.debian.org/sendemail>
sendemail was written by Brandon Zehm from dotconf.net
This manual page was written by Brandon Zehm and improved by Alejandro Garrido Mota, for the Debian project (and may be used by
sendemail-1.56 by Brandon Zehm <firstname.lastname@example.org> Synopsis: sendemail -f ADDRESS [options] Required: -f ADDRESS from (sender) email address * At least one recipient required via -t, -cc, or -bcc * Message body required via -m, STDIN, or -o message-file=FILE Common: -t ADDRESS [ADDR ...] to email address(es) -u SUBJECT message subject -m MESSAGE message body -s SERVER[:PORT] smtp mail relay, default is localhost:25 -S [SENDMAIL_PATH] use local sendmail utility (default: /usr/bin/sendmail) instead of network MTA Optional: -a FILE [FILE ...] file attachment(s) -cc ADDRESS [ADDR ...] cc email address(es) -bcc ADDRESS [ADDR ...] bcc email address(es) -xu USERNAME username for SMTP authentication -xp PASSWORD password for SMTP authentication Paranormal: -b BINDADDR[:PORT] local host bind address -l LOGFILE log to the specified file -v verbosity, use multiple times for greater effect -q be quiet (i.e. no STDOUT output) -o NAME=VALUE advanced options, for details try: --help misc -o message-content-type=<auto|text|html> -o message-file=FILE -o message-format=raw -o message-header=HEADER -o message-charset=CHARSET -o reply-to=ADDRESS -o timeout=SECONDS -o username=USERNAME -o password=PASSWORD -o tls=<auto|yes|no> -o fqdn=FQDN Help: --help the helpful overview you're reading now --help addressing explain addressing and related options --help message explain message body input and related options --help networking explain -s, -b, etc --help output explain logging and other output options --help misc explain -o options, TLS, SMTP auth, and more
sendemail --help misc MISC DOCUMENTATION Misc Options Options that don't fit anywhere else: -a ATTACHMENT [ATTACHMENT ...] -xu USERNAME -xp PASSWORD -o username=USERNAME -o password=PASSWORD -o tls=<auto|yes|no> -o timeout=SECONDS -o fqdn=FQDN -a ATTACHMENT [ATTACHMENT ...] This option allows you to attach any number of files to your email message. To specify more than one attachment, simply separate each filename with a space. Example: -a file1.txt file2.txt file3.txt -xu USERNAME Alias for -o username=USERNAME -xp PASSWORD Alias for -o password=PASSWORD -o username=USERNAME (synonym for -xu) These options allow specification of a username to be used with SMTP servers that require authentication. If a username is specified but a password is not, you will be prompted to enter one at runtime. -o password=PASSWORD (synonym for -xp) These options allow specification of a password to be used with SMTP servers that require authentication. If a username is specified but a password is not, you will be prompted to enter one at runtime. -o tls=<auto|yes|no> This option allows you to specify if TLS (SSL for SMTP) should be enabled or disabled. The default, auto, will use TLS automatically if your perl installation has the IO::Socket::SSL and Net::SSLeay modules available, and if the remote SMTP server supports TLS. To require TLS for message delivery set this to yes. To disable TLS support set this to no. A debug level of one or higher will reveal details about the status of TLS. -o timeout=SECONDS This option sets the timeout value in seconds used for all network reads, writes, and a few other things. -o fqdn=FQDN This option sets the Fully Qualified Domain Name used during the initial SMTP greeting. Normally this is automatically detected, but in case you need to manually set it for some reason or get a warning about detection failing, you can use this to override the default.
apt-cache show sendemail
Maintainer: Alejandro Garrido Mota <email@example.com>
Depends: perl, libio-socket-inet6-perl
Suggests: libio-socket-ssl-perl, libnet-ssleay-perl
Description-en: lightweight, command line SMTP email client
SendEmail is a lightweight, completely command line based, SMTP email
agent. It was designed to be used in bash scripts, Perl programs, and
web sites, but it is also quite useful in many other contexts.
SendEmail is written in Perl and is unique in that it
requires no special modules. It has a straight forward interface,
making it very easy to use.
Tag: implemented-in::perl, interface::commandline, interface::shell,
mail::smtp, mail::user-agent, network::client, protocol::smtp,
protocol::ssl, role::program, use::transmission, works-with::mail
if you get
/scripts/sendemail.sh Jun 13 11:42:17 debian8 sendemail: ERROR => TLS setup failed: SSL connect attempt failed error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
sendemail -o tls=no
the server-way of sending mail and debugging
this does not work out of LAN.
dpkg-reconfigure exim4-config; # configure server-mail-software
echo "" > /var/log/exim4/mainlog; # reset mail log tail -f /var/log/exim4/mainlog & # give immediate output of things that are going on  9092 cat artikel.txt | mail -s "eine Datei" firstname.lastname@example.org; # test mail with 2017-05-22 11:07:39 1dCjJT-0002Mh-Mc <= root@debian U=root P=local S=478 root@debian:/home/user# 2017-05-22 11:07:40 1dCjJT-0002Mh-Mc ** email@example.com R=dnslookup T=remote_smtp X=TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128 DN="C=US,ST=California,L=San Francisco,O=Vesta Control Panel,OU=IT,CN=dwaves.de,EMAILfirstname.lastname@example.org": SMTP error from remote mail server after RCPT TO:<email@example.com>: host dwaves.de [126.96.36.199]: 550-Verification failed for <root@debian>\n550-Unrouteable address\n550 Sender verify failed 2017-05-22 11:07:40 1dCjJU-0002Mm-4N <= <> R=1dCjJT-0002Mh-Mc U=Debian-exim P=local S=1418 2017-05-22 11:07:40 1dCjJT-0002Mh-Mc Completed 2017-05-22 11:07:40 1dCjJU-0002Mm-4N => user <root@debian> R=local_user T=mail_spool 2017-05-22 11:07:40 1dCjJU-0002Mm-4N Completed