Russell Bungay wrote: > Hello all, > > I have written a short function, based on a recipe in the Python > Cookbook, that sends an e-mail. The function takes arguments that > define who the e-mail is to, from, the subject, the body and an optional > list of attachments. > > The function works also perfectly, bar one slight problem. If you > attempt to send an e-mail with just a body and no attachments, the > receiving client still thinks that there is an attachment (so far tested > in Mozilla Thunderbird and the Yahoo! webmail client).
<snip> > Code: > > def sendEmail(msg_to, msg_from, msg_subject, message, attachments=[]): > > main_msg = email.Message.Message() > main_msg['To'] = ', '.join(msg_to) > main_msg['From'] = msg_from > main_msg['Subject'] = msg_subject > main_msg['Date'] = email.Utils.formatdate(localtime=1) > main_msg['Message-ID'] = email.Utils.make_msgid() > main_msg['Mime-version'] = '1.0' > main_msg['Content-type'] = 'Multipart/mixed' > main_msg.preamble = 'Mime message\n' > main_msg.epilogue = '' Would it be the 'Content-Type' header? I've no expertise in this, but doesn't 'multipart' mean 'has attachments'? Gerard -- http://mail.python.org/mailman/listinfo/python-list