Send email through linux console

Hi All,

I have a log file that need to be sent to an email address.

I've tried this script :

echo "This is mail body" | mail -s "This is subject" mymail@mydomain.com

It give me nothing.

Could you provide step by step to configure my linux server so I could send email, and also provide me the script.

A link to other forum would  be fine, if it give clear and detailed information
softblessAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
deepak_iqConnect With a Mentor Commented:
Check:
#/etc/init.d/sendmail status

It might be possible that it is not running.

Do,
#/etc/init.d/sendmail restart

Hopefully,your mail would be on its way at your mailbox.
0
 
savoneConnect With a Mentor Commented:
Try something like this in bash:

cat - file.log << EOF | sendmail -t
to:recipient@domain.com
from:you@domain.com
subject:Log File

EOF
0
 
hemmiCommented:
You should first have a look at the maillog to see what happened. There are numerous reasons for the failure of a mail.
The logs you'll find under /var/log.


0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
c_a_n_o_nConnect With a Mentor Commented:
Being somewhat a novice at this myself, I used a simple perl script that someone wrote called sendEmail.  It will use an alternate SMTP connection. It is quick to setup, simplified instructions here:
http://it.megocollector.com/?p=1290

Original source, with examples.
http://caspian.dotconf.net/menu/Software/SendEmail/
0
 
c_a_n_o_nCommented:
In my testing and quick learning curve with it, I was able to emails with attachments.
0
 
vipul999Commented:
if you are asking this not for any programming use.. then i would suggest you check out pine
0
 
ajay_mhasalConnect With a Mentor Commented:
Hi,

If you wish to send the log file in the body of the mail itself then use following command

mail -s "Log file" abc@xyz.com < log-file.log

And if you wish to send it as attachment then you must have a mutt installed on your system if not grab then

# yum install mutt

Or download rpm of mutt from net and install manually as follows

# rpm -ivh mutt-<version>.rpm

Now create a file having body contents of the mail ( im considering  /tmp/body.txt in following eg.)

mutt -s "Log file" -a /path/to/logfile.log abc@xyz.com < /tmp/body.txt

0
 
softblessAuthor Commented:
Hi Guys,

Please response :
@savone, I've tried :
cat - config.txt << EOF | sendmail -t
to:email1@yahoo.com
from:email2@gmail.com
subject:Log File
EOF
It doesn't give error message when I execute it, but I don't receive the email

The same thing goes to commands that was given by @ajay

@hemmi, i cannot understand the log.

I'll attach the mailloh in this post.

@c_a_n_o_n I've tried installing the sendEmail, but I got error message. If I use this commad :
sendEmail -f mygmail.email@gmail.com -t myyahooemail@yahoo.com \
-u this is the test tile -m “this is a test message” \
-s smtp.gmail.com \
-o tls=auto \
-xu mygmail.email -xp mygmailpassword
The error message will be :
Apr 07 08:34:45 localhost sendEmail[5476]: NOTICE => Authentication not supported by the remote SMTP server!
Apr 07 08:34:46 localhost sendEmail[5476]: ERROR => Received:       530 5.7.0 Must issue a STARTTLS command first. v26sm7259924qce.13

and If I use this command :
sendEmail -f mygmail.email@gmail.com -t myyahooemail@yahoo.com \
-u this is the test tile -m “this is a test message” \
-s smtp.gmail.com \
-o tls=yes \
-xu mygmail.email -xp mygmailpassword

the error message will be :
Apr 07 08:38:40 localhost sendEmail[5601]: ERROR => No TLS support!  SendEmail can't load required libraries. (try installing Net::SSLeay and IO::Socket::SSL)

Please kindly response... thank you.
maillog
0
 
LinuxGuruConnect With a Mentor Linux Server AdministratorCommented:
Hi,

Could you please try installing the TLS Support?

Starting with sendEmail v1.54, TLS support is included! To enable TLS support simply install the Net::SSLeay and IO::Socket::SSL perl modules. The following new command line parameters are now available:
    -o tls=auto This is the default, TLS will be used if possible.
    -o tls=yes Use this to require TLS for message delivery.
    -o tls=no Use this to disable TLS support.
If TLS is giving strange errors, try upgrading the Net::SSLeay and IO::Socket::SSL perl modules.

Please refer the following link.

http://www.linuxjournal.com/article/4823
0
 
Dave BaldwinFixer of ProblemsCommented:
Sending email to Yahoo can be difficult.  They block a lot of things.  The fact that your From address isn't going to match your server address may make it harder also.  Do you have other email addresses that you can use?  For test purposes, it would be nice if they Didn't have spam blocking.

I think I would first get a standard email program working on your server to make sure that works.
0
 
softblessAuthor Commented:
@testez, could you give command to install the Net::SSLeay and IO::Socket::SSL perl modules?
0
All Courses

From novice to tech pro — start learning today.