Giter Club home page Giter Club logo

sendemail's Introduction

sendEmail - Send email from a console near you!
Written by: Brandon Zehm <[email protected]>
http://caspian.dotconf.net/
http://www.tsheets.com/



------------------
What is sendEmail?
------------------

SendEmail is a lightweight, completly command line based, SMTP email agent.
If you have the need to send email from the command line, this tool is perfect.
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 an intuitive and
flexible set of command-line options, making it very easy to learn and use.




------------------
Installation
------------------

SendEmail is a perl script/program, and only needs to be copied to a directory
in your path to make it accessible.  Most likely the following steps will
be sufficient:

1) Extract the package
    tar -zxvf sendEmail-v1.XX.tar.gz

2) Copy the sendEmail script to /usr/local/bin
    cp -a sendEmail-v1.XX/sendEmail /usr/local/bin

3) Make sure its executable
    chmod +x /usr/local/bin/sendEmail

4) Run it
    sendEmail
      or
    /usr/local/bin/sendEmail

NOTES:
  * Running sendEmail without any arguments will produce a usage summary.
  * SendEmail is written in Perl, so no compilation is needed.
  * On a Unix/Linux OS if your perl binary is not installed at /usr/bin/perl
    you may need to edit the first line of the script accordingly.






---------------
Usage Overview
---------------

sendEmail-1.56 by Brandon Zehm <[email protected]>

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

  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|other>
        -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



---------------
Examples
---------------

Simple Email:
  sendEmail -f [email protected]        \
            -t [email protected]    \
            -s smtp.gmail.com:587  \
            -xu [email protected]       \
            -xp MY-PASSWORD        \
            -u "Test email"        \
            -m "Hi buddy, this is a test email."

Sending to mutiple people:
  sendEmail -f [email protected] \
            -t "Scott Thomas <[email protected]>" [email protected] [email protected] \
            -s relay.isp.net     \
            -u "Test email"      \
            -m "Hi guys, this is a test email."

Sending to multiple people using cc and bcc recipients:
(notice the different way I specified multiple To recipients, you can do this for cc and bcc as well)
  sendEmail -f [email protected] \
            -t [email protected];[email protected];[email protected] \
            -cc [email protected] [email protected] [email protected] \
            -bcc [email protected] [email protected] [email protected] \
            -s relay.isp.net \
            -u "Test email with cc and bcc recipients" \
            -m "Hi guys, this is a test email."


Sending to multiple people with multiple attachments:
  sendEmail -f [email protected] \
            -t [email protected] \
            -cc [email protected] [email protected] [email protected] \
            -s relay.isp.net \
            -u "Test email with cc and bcc recipients" \
            -m "Hi guys, this is a test email." \
            -a /mnt/storage/document.sxw "/root/My Documents/Work Schedule.kwd"


Sending an email with the contents of a file as the message body:
  cat /tmp/file.txt | sendEmail -f [email protected] \
                                -t [email protected] \
                                -s relay.isp.net \
                                -u "Test email with contents of file"


Sending an email with the contents of a file as the message body (method 2):
  sendEmail -f [email protected] \
            -t [email protected] \
            -s relay.isp.net \
            -o message-file=/tmp/file.txt \
            -u "Test email with contents of file"


Sending an html email:  (make sure your html file has <html> at the beginning)
  cat /tmp/file.html | sendEmail -f [email protected] \
                                 -t [email protected] \
                                 -s relay.isp.net \
                                 -u "Test email with html content"









------------
Contributors
------------

Many thanks go to the people who have submitted ideas and patches.
I know I've forgotten to mention everyone who's helped with sendEmail,
but here is a small list.  Please let me know if you feel your name
should be here!

  v1.56
   - Several people submitted fixes for the authentication bug.
     Thanks to all of you for nagging me to get this release out!

  Simon Matter (v1.55)
   - Local bind address patch

  CBL Team <http://cbl.abuseat.org/> and Chris Peay (v1.55)
   - Bug reports about sendEmail causing people get blacklisted.

  Jared Cheney (v1.42)
   - More bare LF bug fixes and bare period encoding.
   - Mime encoding patch

  Buddy Nahay (v1.41)
   - Bare LF bug report

  John Rouillard (v1.41)
   - html detection bug report

  Reidar Johansen (v1.40)
   - Added support for HTML email
   - Created a function called tz_offset that determines the local timezone
   - Many other fixes and suggestions

  Paul Kreiner (v1.40)
   - Submitted a patch that forces the timestamp string to always follow
     the HH:MM:SS convention required by the RFCs.

  Al Danial
   - Found and reported a logging/typo/attachment issue in v1.32

  Svante Gerhard
   - Found and reported the file attachment/padding issue in v1.31

  Charles Leeds
   - Put together all the original file attachment code and got me
     on the path to v1.3x
   - Provided the compiled Windows executable version of sendEmail
     for a LONG time.  I really appreciate your help!

  Nick Pasich
   - Passing the email message via STDIN
   - Multiple <to> recpients
   - Log file option
   - Quiet option
   - Cc option
   - Lots of other suggestions and code

  Richard Duim
   - For mime/content-type/attachment suggestions

  Ulisses Montenegro
   - First one to report problems with bare LF's on qmail servers

  Michael Santy
   - Reported problems with various SMTP servers and helped me fix a few
     fairly serious problems.

  Many other people have submitted bug reports and helped to make sendEmail
  what it is today, and my best regards go out to all those .. complainers ;-)

sendemail's People

Contributors

mogaal avatar shtrom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sendemail's Issues

Question: how to send S/MIME-encrypted emails

There are some automated emails that I want to send encrypted using S/MIME. I have the recipients public key file in .pem format, I have a file, let's say "message.txt", that I want to send him, so I can encrypt it like

openssl smime -encrypt -out message-encrypted -in message.txt public-key.pem

The result looks like:

MIME-Version: 1.0
Content-Disposition: attachment; filename="smime.p7m"
Content-Type: application/pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"
Content-Transfer-Encoding: base64

<ENCRYPTED BODY>

So how do I send this with sendEmail, so that the recipient (who has the corresponding private key) will receive it in a way so that his GUI email client (e.g. Apple Mail) will automatically decrypt the contents?

Hostname verification failed

Hi I am struggling with this, I get the following error,

Use of uninitialized value $2 in concatenation (.) or string at /usr/share/perl5/IO/Socket/SSL.pm line 792.
May 02 11:51:03 kali sendemail[50331]: ERROR => TLS setup failed: hostname verification failed

Please assist.

Cant send a single mail

I cant even seen single mail
Command that I used is :-
senemail -f **@gmail.com -t **@gmail.com -m "test" -xu "username" -xp "password"

The output that I get is:-
Connection refused =>

The ordinal 131 could not be located in the dynamic link library

I have a Server 2012 R2 machine that won't run sendEmail. When ever I run it I get the "The ordinal 131 could not be found in the dynamic link library c:\users\USERID\AppData\Local\Temp\pdk-USERID\f72f556d99dfb6b0c3bb3f123e2ee96.dll.

I am running this on other 2012R2 Servers with no issue. Any ideas?

email least file

wanted to ask if there is any option of sending emails to an email least of a any file type

including attachment in message body

Is there any way to include an attachment in the message body? I have a fairly lengthy text attachment that includes escape characters, etc., and it seems problematic to use the -m flag. What I want is for -a to put the text straight into the message body like cat.

sendemail TLS Error - New error after of years OK - SMTP of Google

Hello, thanks for your excellent job.

I'm spanish, from Tenerife ( Canary Island )

I'm trying send a email vía script using your program "sendemail" as always but today show this error:

imagen

INFO => Sending: STARTTLS
Mar 17 16:12:19 bttf2 sendemail[9496]: SUCCESS => Received: 220 2.0.0 Ready to start TLS
Mar 17 16:12:19 bttf2 sendemail[9496]: ERROR => TLS setup failed: SSL connect attempt failed error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

I had been searching for solution but I don't find it.

My script is the same from 4 years ago and the server hasn't new updates.

sendemail -f "Server <[email protected]>" -t [email protected] -s smtp.gmail.com:587 -o message-header=Reintento -u
"Nuevo Intento de Clave fallida" -m "$IP" -v -xu prueba -xp xxxzzzyyy -o tls=yes

I have reviewed the configuration of my account of Google and all OK.

Do you known as solve it ?

All my servers use your program for send emails.

Thanks for all.

reply to not working

hello, the -o reply-to=address is not working, is there any way around it pls?

Sendemail TLS Problem with Exchange 2019

C:\scripts>sendemail.exe -t [email protected] -f [email protected] -u test -m test -s xxx.xx:587 -xu xxx -xp ppp -v -v -o tls=yes
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: DEBUG => Connecting to xxx.xx:587
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: DEBUG => My IP address is: 192.168.138.48
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: DEBUG => evalSMTPresponse() - Found SMTP success code: 220
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: SUCCESS => Received:     220 xxx.xx Microsoft ESMTP MAIL Service ready at Tue, 9 Jun 2020 23:19:12 +0200
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: INFO => Sending:         EHLO i5-3470s
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: DEBUG => evalSMTPresponse() - Found SMTP success code: 250
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: SUCCESS => Received:     250-xxx.xx Hello [IP-hidden], 250-SIZE 37748736, 250-PIPELINING, 250-DSN, 250-ENHANCEDSTATUSCODES, 250-STARTTLS, 250-AUTH GSSAPI NTLM, 250-8BITMIME, 250-BINARYMIME, 250-CHUNKING, 250 SMTPUTF8
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: DEBUG => The remote SMTP server supports TLS :)
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: DEBUG => Starting TLS
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: INFO => Sending:         STARTTLS
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: DEBUG => evalSMTPresponse() - Found SMTP success code: 220
Jun 09 23:19:14 i5-3470s sendemail.exe[23352]: SUCCESS => Received:     220 2.0.0 SMTP server ready
Jun 09 23:19:15 i5-3470s sendemail.exe[23352]: ERROR => **TLS setup failed: SSL connect attempt failed because of handshake problemserror:00000000:lib(0):func(0):reason(0)**

Everytime excatly this error with sendemail, why and what is the error trying to say?

Image embedded using Content-ID header

Is there anyway to embed images using "cid:image.png"? I can easily reference the cid in the body html... But how do I set the reference between the attached image file (using -a), and the Content-ID.

I've seen ways to do this with java setting multipart classes. But don't see how to translate that to sendEmail options.

Thanks

not working at all

i have added the argument with this line of code -f dan9****@gmail.com -t dan07******@gmail.com -u test -m testing -s smtp.gmail.com:587 -xu dan9****@gmail.com -xp my email password -o tls=yes . it does not work at all after i try to set a task schedular on window by start the sendEmail.exe program why this happen to me :(

message body (HTML)

hello please help with sending a message body as html

like the -m option how can i send email as an html template

sendemail trough exchange server smtp ssl / starttls problem

when i try to send 50 emails using sendemail i get this log in a random number .
command im using is this :
sendemail -l email.log
-f "[email protected]"
-u "Automatic email"
-t "[email protected]"
-s "smtp.mailserver.com:587"
-o tls=yes
-xu "username"
-xp "password"
-o message-file="tempemailbody.txt"

with gmail and postfix there is no such problem .
this is not because of network , i did netcat to exchange server and even telnet to verify before sending each email but happened again .
ERROR => TLS setup failed: SSL connect attempt failed error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

sending email using ssmtp has no problem with exchange server

Encoding the filenames

The filenames of the attachments are being sent as-is, which is problematic, when the filenames contain characters outside ASCII:

sendemail -f sender@example   \
          -t receiver@example \
          -a 'Příliš žluťoučký kůň' < /dev/null

This is the message received:

------MIME delimiter for sendEmail-686272.929961891
Content-Type: text/plain;
        name="Příliš žluťoučký ků�"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=""Příliš žluťoučký ků�""

------MIME delimiter for sendEmail-686272.929961891--

This is what we should be receiving:

------MIME delimiter for sendEmail-686272.929961891
Content-Type: text/plain;
        name="=?UTF-8?B?UMWZw61sacWhIMW+bHXFpW91xI1rw70ga8WvxYg=?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
        filename="=?UTF-8?B?UMWZw61sacWhIMW+bHXFpW91xI1rw70ga8WvxYg=?="

------MIME delimiter for sendEmail-686272.929961891--

The following perl command is used to obtain the encoded MIME header as described by the MIME Words standard (see RFC 2047):

$ perl -Mutf8 -MEncode -E 'say encode("MIME-Header", "Příliš žluťoučký kůň")'
=?UTF-8?B?UMWZw61sacWhIMW+bHXFpW91xI1rw70ga8WvxYg=?=

errror : tar -zxvf sendEmail-v1.XX.tar.gz

tar -zxvf sendEmail-v1.XX.tar.gz
tar (child): sendEmail-v1.XX.tar.gz: Cannot perform open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

I already installed it and it doesn't work, i open the file from all the folders but it keeps saying that it can't find it, I don't know what to do anymore. ?

How to remove E-Mail header

Hey i use sendmail and MUX for an error reporting system.

But i want to anonymus the send mail.
In attachted log files i use sed to remove IP, E-Mail etc. But how i can remove sensitive data Form header ?

Discard empty messages

How can I get the same behaviour of '-E' option of classical "mail" program?

       -E     If an outgoing message does not contain any text in its first or only message part, do not send it but discard it silently, effectively setting the skipemptybody  vari-
              able at program startup.  This is useful for sending messages from scripts started by cron(8).

full output mesage

Hi
I'm sorry this is question - not an issue but I couldnt find a better place to ask.

is there any possibility to get full output message (even without setting up connection and sending the email)? I mean some debug option without actual email sending.

thank you, Tomas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.