SendEmail is a lightweight, completly 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
Install sendemail in debian lenny
#apt-get install sendemail
This will complete the installation.
If you are using Debian Etch you need to compile sendemail from source
Preparing your system
#apt-get install libio-socket-ssl-perl libnet-ssleay-perl perl
Download latest version from here
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.55.tar.gz
Uncompress the .tar.gz
#tar zxvf /tmp/sendEmail-v1.55.tar.gz
#cd /tmp/sendEmail-v1.55
Copy the sendEmail script to /usr/local/bin
#cp /tmp/sendEmail-v1.55/sendEmail /usr/local/bin
Make sure its executable
#chmod +x /usr/local/bin/sendEmail
Sendemail Examples
Simple Email Using Gmail Account
sendEmail -f [email protected] -t [email protected] \
-u this is the test tile -m “this is a test message” \
-s smtp.gmail.com \
-o tls=yes \
-xu usernameonly -xp mypasswd
“usernameonly” must not contain @gmail.com only the username.
Simple Email
sendEmail -f [email protected] \
-t [email protected] \
-s relay.isp.net \
-u “Test email” \
-m “Hi , this is a test email.”
Sending to mutiple people
sendEmail -f [email protected] \
-t “admin <[email protected]>” [email protected] [email protected] \
-s relay.isp.net \
-u “Test email” \
-m “Hi this is a test email.”
Sending to multiple people using cc and bcc recipients
(notice the different way we 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 his 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 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”
Send Short Message Service (SMS)/text message to a cellular phone
Simple Text Message Sent To Cellular Phone Using Gmail Account
./sendEmail -f [email protected] -t [email protected] \
-m This is an SMS message from Linux.\
-o tls=auto \
-s smtp.gmail.com \
-xu usernameonly -xp mypasswd
Providers
What’s my SMS Email address?
AT&T [email protected]
Example: [email protected]
Cingular [email protected]
Metrocall [email protected]
Nextel [email protected]
Sprint PCS [email protected]
T-Mobile [email protected]
Verizon [email protected]
ALLTEL [email protected]
Also see esmtp, it’s compatible with sendmail.
Thank You.
I had tried this a year or two ago and gave up easily. I am using Ubuntu 8.10, synaptics for sendemail then a hybrid of your “Simple Email using Gmail account” and “Simple Email”. I’m not using gmail but for a simple email I used fields -f -t -s -xu -xp -u -m
-s mail.mydomain.net
I have an Etch server up and running, and followed the instructions here. They worked perfectly, and the script executed successfully, but I am not receiving the email. Perhaps there is a server or router configuration I am missing? Here is the verbose output from my test email.
May 28 16:11:43 myprivateserver sendEmail[29676]: DEBUG => Connecting to localhost:25
May 28 16:11:43 myprivateserver sendEmail[29676]: DEBUG => My IP address is: 127.0.0.1
May 28 16:11:43 myprivateserver sendEmail[29676]: DEBUG => evalSMTPresponse() - Found SMTP success code: 220
May 28 16:11:43 myprivateserver sendEmail[29676]: SUCCESS => Received: 220 myprivateserver.launchmodem.com ESMTP Exim 4.63 Thu, 28 May 2009 16:11:43 -0400
May 28 16:11:43 myprivateserver sendEmail[29676]: INFO => Sending: EHLO myprivateserver.launchmodem.com
May 28 16:11:43 myprivateserver sendEmail[29676]: DEBUG => evalSMTPresponse() - Found SMTP success code: 250
May 28 16:11:43 myprivateserver sendEmail[29676]: SUCCESS => Received: 250-myprivateserver.launchmodem.com Hello root at localhost [127.0.0.1], 250-SIZE 52428800, 250-PIPELINING, 250 HELP
May 28 16:11:43 myprivateserver sendEmail[29676]: DEBUG => The remote SMTP server does NOT support TLS :(
May 28 16:11:43 myprivateserver sendEmail[29676]: NOTICE => Authentication not supported by the remote SMTP server!
May 28 16:11:43 myprivateserver sendEmail[29676]: INFO => Sending: MAIL FROM:
May 28 16:11:43 myprivateserver sendEmail[29676]: DEBUG => evalSMTPresponse() - Found SMTP success code: 250
May 28 16:11:43 myprivateserver sendEmail[29676]: SUCCESS => Received: 250 OK
May 28 16:11:43 myprivateserver sendEmail[29676]: INFO => Sending: RCPT TO:
May 28 16:11:43 myprivateserver sendEmail[29676]: DEBUG => evalSMTPresponse() - Found SMTP success code: 250
May 28 16:11:43 myprivateserver sendEmail[29676]: SUCCESS => Received: 250 Accepted
May 28 16:11:43 myprivateserver sendEmail[29676]: INFO => Sending: DATA
May 28 16:11:43 myprivateserver sendEmail[29676]: DEBUG => evalSMTPresponse() - Found SMTP success code: 354
May 28 16:11:43 myprivateserver sendEmail[29676]: SUCCESS => Received: 354 Enter message, ending with "." on a line by itself
May 28 16:11:43 myprivateserver sendEmail[29676]: INFO => Sending message body
May 28 16:11:43 myprivateserver sendEmail[29676]: DEBUG => Sending the attachment [webFileCheckLog.txt]
May 28 16:11:43 myprivateserver sendEmail[29676]: DEBUG => evalSMTPresponse() - Found SMTP success code: 250
May 28 16:11:43 myprivateserver sendEmail[29676]: SUCCESS => Received: 250 OK id=1M9lx1-0007if-EM
May 28 16:11:43 myprivateserver sendEmail[29676]: Email was sent successfully! From: To: Subject: [test] Attachment(s): [webFileCheckLog.txt] Server: [localhost:25]
ERROR => Timeout while connecting to smtp.gmail.com:25 There was no response after 60 seconds.
I just started getting the ERROR => Timeout while connecting to smtp.gmail.com:25 There was no response after 60 seconds.
Seems AT&T just started blocking port 25 without allowing an open port!
Hi guys,
please a have same trouble like a Scott :-/
ERROR => Timeout while connecting to smtpa.fopsi.com:25 There was no response after 60 seconds.
my firewall is open [iptables -P OUTPUT ACCEPT], and smtpa.forpsi.com server is pingable without problems..
Any idea what can be wrong about it? Or about my hand..? 🙂
THX a lot
Re: Gmail, try: smtp.gmail.com:587. My ISP blocks port 25, but 587 works for Gmail.
I tried
sendEmail -v -v -f [email protected] -t [email protected] -m "test" -u "test:)" -o tls=auto -s smtp.seznam.cz -xu sacad -xp ****************
but result was this error
sendEmail[2662]: ERROR => Received: 501 Command too short.
AUTH was successful… so what is wrong?
I tried with seznam too, but every time I receive EXITING: SIGINT
but everything is set correctly…………….
so what is wrong? thanx:)
how to send mail from website to webadmin account by smtp server in html code
I’m on Ubuntu 10.04 LTS and sending to port 25 (587) works as expected. Sending to port 465 with tls give me a seg fault. Verbose output consists of:
$ sendemail -f me -t them -m “message” -o tls=auto -s smtp.gmail.com:465 -xu myid -xp mypass -v
Jan 18 18:19:40 sendemail[10458]: DEBUG => Connecting to smtp.gmail.com:465
Jan 18 18:19:41 sendemail[10458]: DEBUG => My IP address is: 192.168.0.100
Segmentation fault
Error When Crontab Run
grep CRON /var/log/syslog
CRON[6341]: (root) CMD (bash /usr/local/bin/backup.sh)
CRON[6340]: (CRON) info (No MTA installed, discarding output)
I’m facing the same error than 11 (Larry) using gmail smtp server through port 25. Anybody have solved it?
Thanks in advance
I’m with Larry and Dani— segmentation fault when using port 465 in sendemail. I got exactly the same printout as Larry except for the last byte of the IP address— perchance because he too is a CenturyLink customer and thus likewise bought a Qwest-configured DSL modem of the ActionTec make which comes preset to 192.168.0.1, with a DHCP server inside and a bitmask of 255.255.255.0 (though that’s a common setup).
[Editorial note: I’m new to Linux/Ubuntu and hardly know what I’m doing. Back to my narrative…]
I was simply trying to send email to myself, such as to notify me of successful backups. It was my out-of-state ISP (the ISP that hosts my website and provides an email account for me and not the ISP for my DSL line, CenturyLink, whose smtp server didn’t work for me with port 465 and SSL either) that advised me to use port 465 for SSL. Strangely, I had no trouble at all with Thunderbird, the Mozilla email client, on the very same computer. It set up easily on port 465 with SSL/TLS and it works without any problems.
Throughout this struggle with sendemail I had ignored my out-of-state ISP’s advice for non-SSL transmissions, which was to get around the spam-avoidance practice of some ISPs (evidently Century Link too) of blocking port 25… by using port 2525 instead. So I tried it, without setting tls=yes.
Voila (and I hope that my French teachers— may the ones that are gone rest in peace— will forgive me for not knowing how to put the accent on the last letter)! Success.
Here’s what worked:
Sample:
sendEmail -f [email protected] -t [email protected] \
-u “this is the test email” -m “this is a test message” \
-s mail.myoutofstateISP.net:2525 \
-xu myusername[[email protected]] -xp mypassword \
-v -v
Somehow that averts the segmentation fault problem for me, but of course I have no idea why. Note that some ISPs, quite possibly gmail but I’m not sure, would have you put your entire email address with the @domain.com or whatever on the end of the -xu parameter. Not so at my particular out-of-state ISP.
Strangely the mail comes through with some hair on it, some vestiges of the quotes are draped around the body… but none around the subject. But I can live with that.
Thanks all, for your help.
sendEmail -f [email protected] -t [email protected] \
-u “this is the test email” -m “this is a test message” \
-s mail.myoutofstateISP.net:465 \
-xu myusername[[email protected]] -xp mypassword \
-v -v
Use windows version, system say, and after this no reply from window…
Dec 16 13:46:42 osipov sendEmail[728]: DEBUG => Connecting to smtp.gmail.com:
Dec 16 13:46:42 osipov sendEmail[728]: DEBUG => My IP address is: 127.0.0.1
TIMEOUT: If you are getting time’d out, you should specify gmail’s smtp server’s port:
smtp.gmail.com:587
Source: http://support.google.com/mail/bin/answer.py?hl=en&answer=13287
Enjoy.
Here is the Windows command that worked for me.
sendEmail -f [email protected] -t [email protected] -u “this is the subject” -m “this is a test message body” -s smtp.gmail.com:587 -o tls=yes -xu [email protected] -xp password
Can you also include examples of how to directly connect to Gmail’s SMTP server from command line and do stuff like STARTTLS and authentication?
The prog work fine on win 7 i execute it through delphi code but the problem is that -o message-charset=utf-8 dont work for me and i cant send greek characters. Any idea?
But how do you actually SEND what you’ve typed? What is the command to SEND the email? All I get is new lines when I hit return and there is no information in the MAN page on how to actually SEND what you’ve written. Quite frustrating.
@Wulfmaer, the sendEmail program tells you how to SEND the email. It’s different on Linux vs Windows. On Linux it’s Ctrl-D, on Windows it’s Ctrl-Z IIRC.
I’m having trouble with the cat in front of the sendemail command it’s not sending the email. Using xp on this machine
I can get the sendEmail part working (with Gmail as smtp) – now just have to figure out how to sort teh SSL_verify_mode out 🙂