[CentOS] how to send mail from console

Timothy Murphy gayleard at eircom.net
Fri Jan 15 14:23:10 UTC 2010


Roland Roland wrote:

> i'm trying to get a script to send me an email whenever a certain
> condition takes place..
> i'm afraid i dont have experience with mail command nor anything else
> related to sending emails for that matter..
> 
> i googled a bit and tried using mutt and mail ...
> though i do not recieve any email in my inbox...
> 
> the command im using is the following : mail -s “disk space report”
> R_O_L_A_N_D at hotmail.com
> 
> should i setup a default smtp to use? where can i check for the errors
> that are taking place?

I shouldn't really post this, as I am so far from being an expert,
but I use the following script to send (daily) the email address 
of a remote machine:
---------------------------------------
#!/usr/bin/python

SENDMAIL = "/usr/sbin/sendmail"
import os
import sys
import time
tt = time.ctime()
f = os.popen("stunbdc stun.ekiga.net 2>/dev/null")
ipaddr = f.read()
f.close()
p = os.popen("%s -t -fgayleard at alice.it" % SENDMAIL, "w")
p.write("To: gayleard at eircom.net\r\n")
p.write("From: Timothy Murphy <gayleard at alice.it>\r\n")
p.write("Subject: Anghiari IP address\r\n")
p.write("\r\n")
p.write(tt + "\r\n")
p.write(ipaddr + "\r\n")
p.close()
sys.exit()
---------------------------------------

I found I have to add the -f switch (with a local address)
to satisfy the remote ISP.

But this is probably far from your needs.

-- 
Timothy Murphy  
e-mail: gayleard /at/ eircom.net
tel: +353-86-2336090, +353-1-2842366
s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland



More information about the CentOS mailing list