Hi all, I have a python script that works out & emails my employer with parts that I have used. It has been great for 11ish months, now all my mail is classed as spam & junked :(
Apparently the reason for it being junked is ... 'No subject' and 'No Sender' I set up a small test script to isolate the problem using the core of the email code ... #!/usr/bin/env python # -*- coding: iso8859_1 -*- from smtplib import SMTP from time import sleep, strftime from datetime import datetime import sys email_SMTP = 'mail.pusspaws.net' email_addr = '[EMAIL PROTECTED]' def email_test(): for trys in xrange(10): try: mail_server = SMTP(email_SMTP) mail_server.login('XXXX', 'XXXX') subject = 'Test Email' from_ = 'Dave Selby<[EMAIL PROTECTED]>' to = email_addr return_path = email_addr blog="""Hi,\n\nThis is just a test""" msg = mail_headers(subject, from_, to, return_path) +'\r\n\r\n'+blog mail_server.sendmail(subject , email_addr, msg) mail_server.quit() # If we get to here, all is well, drop out of the loop break except: print 'Mailing error ... Re-trying ... '+str(trys+1)+' of 10\n' sleep(300) if trys==9: raise 'Mail Failure\n'+str(sys.exc_type)+'\n'+str(sys.exc_value) def mail_headers(subject, from_, to, return_path): """ Generate a formatted mail header string """ header = 'Return-Path: ' + return_path header = header + '\r\nFrom: ' + from_ header = header + '\r\nReply-To: ' + return_path header = header + '\r\nTo: ' + to header = header + '\r\nSubject: '+subject now=datetime.now() day = now.strftime('%a') date = now.strftime('%d %b %Y %X') header = header + '\r\nDate : ' + day + ', ' + date + ' -0000\r\n' return (header) email_test() >From this I receive the following .... Return-Path: <Test> Delivered-To: [EMAIL PROTECTED] Received: (qmail 21696 invoked by uid 503); 6 Dec 2005 20:35:48 -0000 Received: from unknown (HELO localhost.localdomain) ([EMAIL PROTECTED]) by host201.com with SMTP; 6 Dec 2005 20:35:48 -0000 Return-Path: [EMAIL PROTECTED] From: Dave Selby<[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Test Email Date: Tue, 06 Dec 2005 20:35:47 -0000 X-Bogosity: Ham, tests=bogofilter, spamicity=0.288675, version=0.95.2 X-UID: Status: R X-Status: NGC X-KMail-EncryptionState: X-KMail-SignatureState: X-KMail-MDN-Sent: Hi, This is just a test I cannot seem to set the top 'Return-path' correctly, any ideas how I do this ? also I have a sender so I am unsure why the spam filter picked this out. Any suggestions Cheers dave _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor