I write mail.py(use webpy) to send me the ip address of each machine.
#!/usr/bin/env python  
#coding=utf-8
import web  
def send_mail(send_to, subject, body, cc=None, bcc=None):  
    try:  
        web.config.smtp_server = 'xxxxx'   
        web.config.smtp_port = 25    
        web.config.smtp_username = 'xxx'  
        web.config.smtp_password = 'xxx'   
        web.config.smtp_starttls = True  
        send_from = 'xxx'    
        web.sendmail(send_from, send_to, subject, body, cc=cc, bcc=bcc)  
        return 1  #pass  
    except Exception, e:  
        print e  
        return -1 #fail  
if __name__=='__main__':  
    print "in mail.py"
    f=file('/home/spark/Desktop/ip.log') 
    f1=f.read()
    f.close()
    send_to = ['xxxx']          
    subject = 'xxxx'  
    body = 'ip:',f1 
    send_mail(send_to, subject, body) 
rc.local
bash deploy.sh &
exit 0
deploy.sh
#!/usr/bin/env
cd /home/spark/Desktop
python mail.py  >>deploy.log
echo "-----------------------------------------------------------"
I can receive email if I do 'python mail.py'.But when I put it in rc.local, I can not receive the email, the message in deploy.log outputs [Errno -2 ] Name or service not known.
I am puzzled with this output.
 
    