SendEmail is a lightweight command line SMTP agent. It was designed to be easily integrated in bash scripts, Perl programs etc. The program is in fact a Perl script, and it is distributed under GPL.
I’ll start by installing SendEmail, and I will then show how to send the email using a regular gmail.com account or a yahoo.com account. You can send the email to this account, or you can use the account as a relay. The same procedure can be used with most of the online accounts.
Installing SendEmail is easy:
$ sudo apt-get install libio-socket-ssl-perl libnet-ssleay-perl sendemail
Sending an email using gmail.com is as follows:
$ sendemail -f username@gmail.com -t destination@domain.com \
-u “this is the subject of the message” \
-m “and this is the message” \
-s smtp.gmail.com -o tls=yes -xu username -xp password
username and password above are your gmail.com username and password. The message is encrypted using TLS. destination@domain.com is where you want the message to be sent.
Similarly for yahoo.com:
$ sendemail -f username@yahoo.com -t destination@domain.com \
-u “this is the subject of the message” \
-m “and this is the message” \
-s smtp.mail.yahoo.com -xu username -xp password
SendEmail comes with a regular man page and very extensive documentation accessible using –help option. For example:
$ sendemail –help networking
NETWORKING DOCUMENTATION
Networking Options
Options related to networking:
-s SERVER[:PORT]
-b BINDADDR[:PORT]
-o tls=
-o timeout=SECONDS-s SERVER[:PORT]
This option allows you to specify the SMTP server sendEmail should
connect to to deliver your email message to. If this option is not
specified sendEmail will try to connect to localhost:25 to deliver
the message. THIS IS MOST LIKELY NOT WHAT YOU WANT, AND WILL LIKELY
FAIL unless you have a email server (commonly known as an MTA) running
on your computer!
Typically you will need to specify your company or ISP’s email server.
For example, if you use CableOne you will need to specify:
-s mail.cableone.net
If you have your own email server running on port 300 you would
probably use an option like this:
-s myserver.mydomain.com:300
If you’re a GMail user try:
-s smtp.gmail.com:587 -xu me@gmail.com -xp PASSWD-b BINDADDR[:PORT]
This option allows you to specify the local IP address (and optional
tcp port number) for sendEmail to bind to when connecting to the remote
SMTP server. This useful for people who need to send an email from a
specific network interface or source address and are running sendEmail on
a firewall or other host with several network interfaces.-o tls=
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.$
