From szybalski at gmail.com Thu Apr 13 19:47:10 2006 From: szybalski at gmail.com (Lukasz Szybalski) Date: Thu, 13 Apr 2006 12:47:10 -0500 Subject: [Email-SIG] smtplib and getting a copy ? Message-ID: <804e5c70604131047r151aa9a7ra32bc8e3c710fcc1@mail.gmail.com> Hello, I am sending an email with smtplib, and i need to get a copy of what i have sent out. Is there a way to do it? I am storing the information into a database so I need to get message id, time etc from the message that gets sent out. Thanks -- Lukasz Szybalski From barry at python.org Thu Apr 13 19:58:59 2006 From: barry at python.org (Barry Warsaw) Date: Thu, 13 Apr 2006 13:58:59 -0400 Subject: [Email-SIG] smtplib and getting a copy ? In-Reply-To: <804e5c70604131047r151aa9a7ra32bc8e3c710fcc1@mail.gmail.com> References: <804e5c70604131047r151aa9a7ra32bc8e3c710fcc1@mail.gmail.com> Message-ID: <1144951139.7368.18.camel@resist.wooz.org> On Thu, 2006-04-13 at 12:47 -0500, Lukasz Szybalski wrote: > I am sending an email with smtplib, and i need to get a copy of what i > have sent out. > Is there a way to do it? > > I am storing the information into a database so I need to get message > id, time etc from the message that gets sent out. Do you want the mail server to send you a copy, or do you want a copy of what you send to the mail server? If the former, just add a BCC header and include the return address you want the copy sent to. If the latter, just do str(msg) to get the text. -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 309 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/email-sig/attachments/20060413/4b62c633/attachment.pgp From phd at mail2.phd.pp.ru Thu Apr 13 19:53:46 2006 From: phd at mail2.phd.pp.ru (Oleg Broytmann) Date: Thu, 13 Apr 2006 21:53:46 +0400 Subject: [Email-SIG] smtplib and getting a copy ? In-Reply-To: <804e5c70604131047r151aa9a7ra32bc8e3c710fcc1@mail.gmail.com> References: <804e5c70604131047r151aa9a7ra32bc8e3c710fcc1@mail.gmail.com> Message-ID: <20060413175346.GF28963@phd.pp.ru> On Thu, Apr 13, 2006 at 12:47:10PM -0500, Lukasz Szybalski wrote: > I am sending an email with smtplib, and i need to get a copy of what i > have sent out. Add yourself to the list of recipints addresses. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From szybalski at gmail.com Thu Apr 13 20:15:34 2006 From: szybalski at gmail.com (Lukasz Szybalski) Date: Thu, 13 Apr 2006 13:15:34 -0500 Subject: [Email-SIG] smtplib and getting a copy ? In-Reply-To: <1144951139.7368.18.camel@resist.wooz.org> References: <804e5c70604131047r151aa9a7ra32bc8e3c710fcc1@mail.gmail.com> <1144951139.7368.18.camel@resist.wooz.org> Message-ID: <804e5c70604131115q3a022ce5kd6e17fd7eac2e5c1@mail.gmail.com> On 4/13/06, Barry Warsaw wrote: > On Thu, 2006-04-13 at 12:47 -0500, Lukasz Szybalski wrote: > > > I am sending an email with smtplib, and i need to get a copy of what i > > have sent out. > > Is there a way to do it? > > > > I am storing the information into a database so I need to get message > > id, time etc from the message that gets sent out. > > Do you want the mail server to send you a copy, or do you want a copy of > what you send to the mail server? If the former, just add a BCC header > and include the return address you want the copy sent to. If the > latter, just do str(msg) to get the text. Although that works to get what i created i also need to get : Date: Thu, 13 Apr 2006 11:11:17 -0700 (PDT) Message-Id: <443e9445.2a2d498e.545b.68b7SMTPIN_ADDED at mx.gmail.com> Anyway to do it? Does smtplib have a way to return exact thing it is sending? > -Barry > > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2.2 (GNU/Linux) > > iQCVAwUARD6RY3EjvBPtnXfVAQIoFwP9HEayxK92vSYnsv4U9REibulopyFVS/PP > s4NYOkSZdiFhzJvLa5ikLndtWsBlW+7WQcBHjAJQM/Lro15A0OPwwTz/GlMuyRBZ > w3+oJYvA0usfXkyzf599mzWJeDMIVQEn5XI71bCr2A+4d81OdbbZR+B4dc2TyHxE > kokXiQsLVMY= > =UKfv > -----END PGP SIGNATURE----- > > > -- Lukasz Szybalski www.lucasmanual.com From szybalski at gmail.com Thu Apr 13 22:33:57 2006 From: szybalski at gmail.com (Lukasz Szybalski) Date: Thu, 13 Apr 2006 15:33:57 -0500 Subject: [Email-SIG] smtplib and getting a copy ? In-Reply-To: <804e5c70604131115q3a022ce5kd6e17fd7eac2e5c1@mail.gmail.com> References: <804e5c70604131047r151aa9a7ra32bc8e3c710fcc1@mail.gmail.com> <1144951139.7368.18.camel@resist.wooz.org> <804e5c70604131115q3a022ce5kd6e17fd7eac2e5c1@mail.gmail.com> Message-ID: <804e5c70604131333j58edccd7w5067e3d12205b224@mail.gmail.com> Is message id generated by sending server or receiving server? I could create a time stamp, but not sure about message id. The easiest way i see it done, is to enter some kind of debug mode that lets me see what is being transferred and enables me to get a copy of sent message. Lukasz On 4/13/06, Lukasz Szybalski wrote: > On 4/13/06, Barry Warsaw wrote: > > On Thu, 2006-04-13 at 12:47 -0500, Lukasz Szybalski wrote: > > > > > I am sending an email with smtplib, and i need to get a copy of what i > > > have sent out. > > > Is there a way to do it? > > > > > > I am storing the information into a database so I need to get message > > > id, time etc from the message that gets sent out. > > > > Do you want the mail server to send you a copy, or do you want a copy of > > what you send to the mail server? If the former, just add a BCC header > > and include the return address you want the copy sent to. If the > > latter, just do str(msg) to get the text. > > Although that works to get what i created i also need to get : > Date: Thu, 13 Apr 2006 11:11:17 -0700 (PDT) > Message-Id: <443e9445.2a2d498e.545b.68b7SMTPIN_ADDED at mx.gmail.com> > > Anyway to do it? Does smtplib have a way to return exact thing it is sending? > > > -Barry > > > > > > > > -----BEGIN PGP SIGNATURE----- > > Version: GnuPG v1.4.2.2 (GNU/Linux) > > > > iQCVAwUARD6RY3EjvBPtnXfVAQIoFwP9HEayxK92vSYnsv4U9REibulopyFVS/PP > > s4NYOkSZdiFhzJvLa5ikLndtWsBlW+7WQcBHjAJQM/Lro15A0OPwwTz/GlMuyRBZ > > w3+oJYvA0usfXkyzf599mzWJeDMIVQEn5XI71bCr2A+4d81OdbbZR+B4dc2TyHxE > > kokXiQsLVMY= > > =UKfv > > -----END PGP SIGNATURE----- > > > > > > > > > -- > Lukasz Szybalski > www.lucasmanual.com > -- Lukasz Szybalski www.lucasmanual.com From matt at mondoinfo.com Fri Apr 14 00:21:51 2006 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Thu, 13 Apr 2006 17:21:51 -0500 (CDT) Subject: [Email-SIG] smtplib and getting a copy ? Message-ID: <1144966850.52.1997@mint-julep.mondoinfo.com> [Sorry, originally sent this reply directly] Dear Lukasz, > Is message id generated by sending server or receiving server? It's intended to be created by the program that sends the mail, but it's technically optional. The details are at: http://www.faqs.org/rfcs/rfc2822.html If the sending program doesn't create a Message-ID header, one will likely be added by some intermediate server. > I could create a time stamp, but not sure about message id. Python's email module has a convenience function to create one that should be sufficient. It's documented at: http://docs.python.org/lib/module-email.Utils.html For example: >>> import email.Utils >>> email.Utils.make_msgid() '<20060413221549.2140.4129 at mint-julep.mondoinfo.com>' Regards, Matt From msapiro at value.net Fri Apr 14 03:55:01 2006 From: msapiro at value.net (Mark Sapiro) Date: Thu, 13 Apr 2006 18:55:01 -0700 Subject: [Email-SIG] smtplib and getting a copy ? In-Reply-To: <804e5c70604131115q3a022ce5kd6e17fd7eac2e5c1@mail.gmail.com> Message-ID: Lukasz Szybalski wrote: > >Although that works to get what i created i also need to get : >Date: Thu, 13 Apr 2006 11:11:17 -0700 (PDT) >Message-Id: <443e9445.2a2d498e.545b.68b7SMTPIN_ADDED at mx.gmail.com> > >Anyway to do it? Does smtplib have a way to return exact thing it is sending? smtlib sends exactly what you give it. If you don't put Date: and Message-Id: headers in the message you pass to smtplib, your outgoing MTA adds them and the smtplib methods have no way to know what they are. If your application needs to know them, it has to create them and put them in the message as suggested by Matthew in another reply. -- Mark Sapiro The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan From msapiro at value.net Fri Apr 14 04:47:31 2006 From: msapiro at value.net (Mark Sapiro) Date: Thu, 13 Apr 2006 19:47:31 -0700 Subject: [Email-SIG] smtplib and getting a copy ? In-Reply-To: Message-ID: Mark Sapiro wrote: >Lukasz Szybalski wrote: >> >>Although that works to get what i created i also need to get : >>Date: Thu, 13 Apr 2006 11:11:17 -0700 (PDT) >>Message-Id: <443e9445.2a2d498e.545b.68b7SMTPIN_ADDED at mx.gmail.com> >> >>Anyway to do it? Does smtplib have a way to return exact thing it is sending? > >smtlib sends exactly what you give it. If you don't put Date: and >Message-Id: headers in the message you pass to smtplib, your outgoing >MTA adds them and the smtplib methods have no way to know what they >are. Actually, I looked a little more closely, and in your particular case above it seems that at least the Message-Id: header was not added until the message reached gmail.com. -- Mark Sapiro The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan From szybalski at gmail.com Fri Apr 14 19:12:50 2006 From: szybalski at gmail.com (Lukasz Szybalski) Date: Fri, 14 Apr 2006 12:12:50 -0500 Subject: [Email-SIG] smtplib and getting a copy ? In-Reply-To: <1144966445.68.1997@mint-julep.mondoinfo.com> References: <804e5c70604131047r151aa9a7ra32bc8e3c710fcc1@mail.gmail.com> <1144951139.7368.18.camel@resist.wooz.org> <804e5c70604131115q3a022ce5kd6e17fd7eac2e5c1@mail.gmail.com> <804e5c70604131333j58edccd7w5067e3d12205b224@mail.gmail.com> <1144966445.68.1997@mint-julep.mondoinfo.com> Message-ID: <804e5c70604141012t5c1bb4d9u367bcdacbb29d41c@mail.gmail.com> On 4/13/06, Matthew Dixon Cowles wrote: > Dear Lukasz, > > > Is message id generated by sending server or receiving server? > > It's intended to be created by the program that sends the mail, but > it's technically optional. The details are at: > > http://www.faqs.org/rfcs/rfc2822.html > > If the sending program doesn't create a Message-ID header, one will > likely be added by some intermediate server. > > > I could create a time stamp, but not sure about message id. > > Python's email module has a convenience function to create one that > should be sufficient. It's documented at: > > http://docs.python.org/lib/module-email.Utils.html > > For example: > > >>> import email.Utils > >>> email.Utils.make_msgid() > '<20060413221549.2140.4129 at mint-julep.mondoinfo.com>' > great this is what i needed, and for time i used formatdate() One last question. Is there an easy way to covert body of an email into lines starting with ">" If I received in my payload(), body of an email: hello how are you I want to send a response with quoted part: hi >hello >how are you Is quote(str) a function that i would use? From description it seems as it only escapes backslashes and quotes. Thank you Lukasz > Regards, > Matt > > From phd at mail2.phd.pp.ru Fri Apr 14 19:19:19 2006 From: phd at mail2.phd.pp.ru (Oleg Broytmann) Date: Fri, 14 Apr 2006 21:19:19 +0400 Subject: [Email-SIG] smtplib and getting a copy ? In-Reply-To: <804e5c70604141012t5c1bb4d9u367bcdacbb29d41c@mail.gmail.com> References: <804e5c70604131047r151aa9a7ra32bc8e3c710fcc1@mail.gmail.com> <1144951139.7368.18.camel@resist.wooz.org> <804e5c70604131115q3a022ce5kd6e17fd7eac2e5c1@mail.gmail.com> <804e5c70604131333j58edccd7w5067e3d12205b224@mail.gmail.com> <1144966445.68.1997@mint-julep.mondoinfo.com> <804e5c70604141012t5c1bb4d9u367bcdacbb29d41c@mail.gmail.com> Message-ID: <20060414171918.GA26132@phd.pp.ru> On Fri, Apr 14, 2006 at 12:12:50PM -0500, Lukasz Szybalski wrote: > One last question. > Is there an easy way to covert body of an email into lines starting with ">" > > If I received in my payload(), body of an email: > hello > how are you > > I want to send a response with quoted part: > hi > >hello > >how are you body = message.get_payload() answer = ["> %s" % line for line in body.split('\n')] reply = '\n'.join(answer) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From phd at mail2.phd.pp.ru Fri Apr 14 19:27:22 2006 From: phd at mail2.phd.pp.ru (Oleg Broytmann) Date: Fri, 14 Apr 2006 21:27:22 +0400 Subject: [Email-SIG] Make reply Message-ID: <20060414172722.GA26461@phd.pp.ru> Barry, woulnt't it be a nice addition? def make_reply(body, quote_str="> "): return '\n'.join([quote_str + line for line in body.split('\n')]) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From matt at mondoinfo.com Fri Apr 14 19:27:06 2006 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Fri, 14 Apr 2006 12:27:06 -0500 (CDT) Subject: [Email-SIG] smtplib and getting a copy ? In-Reply-To: <804e5c70604141012t5c1bb4d9u367bcdacbb29d41c@mail.gmail.com> References: <804e5c70604131047r151aa9a7ra32bc8e3c710fcc1@mail.gmail.com> <1144951139.7368.18.camel@resist.wooz.org> <804e5c70604131115q3a022ce5kd6e17fd7eac2e5c1@mail.gmail.com> <804e5c70604131333j58edccd7w5067e3d12205b224@mail.gmail.com> <1144966445.68.1997@mint-julep.mondoinfo.com> <804e5c70604141012t5c1bb4d9u367bcdacbb29d41c@mail.gmail.com> Message-ID: <1145035448.36.2229@mint-julep.mondoinfo.com> Dear Lukasz, > Is there an easy way to covert body of an email into lines starting > with ">" Oleg is of course quite right. Depending on your exact needs, you may also find the textwrap module useful: http://docs.python.org/lib/module-textwrap.html Regards, Matt From mj at zopatista.com Fri Apr 14 20:31:29 2006 From: mj at zopatista.com (Martijn Pieters) Date: Fri, 14 Apr 2006 20:31:29 +0200 Subject: [Email-SIG] Make reply In-Reply-To: <20060414172722.GA26461@phd.pp.ru> References: <20060414172722.GA26461@phd.pp.ru> Message-ID: <443FEA81.2090004@zopatista.com> Oleg Broytmann wrote: > Barry, woulnt't it be a nice addition? > > def make_reply(body, quote_str="> "): > return '\n'.join([quote_str + line for line in body.split('\n')]) I think there is a bit more to quoting than just prepending a quotemark; it also depends on the email format. I guess that that function (with splitlines() perhaps) would do for "text/plain"; but for "text/plain; format=flowed" (note the qualifier, quote formatting is explicitly defined in an RFC, and you might want to use a specialized module to handle that. I have such a module at the ready at: http://www.zopatista.com/projects/formatflowed which handles correct wragging as well. Martijn Pieters -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature Url : http://mail.python.org/pipermail/email-sig/attachments/20060414/159cce05/attachment.pgp From barry at python.org Wed Apr 19 20:14:28 2006 From: barry at python.org (Barry Warsaw) Date: Wed, 19 Apr 2006 14:14:28 -0400 Subject: [Email-SIG] Python patch submittion 1464708 In-Reply-To: <1145461496.9715.21.camel@tardis.cisco.com> References: <1145461496.9715.21.camel@tardis.cisco.com> Message-ID: <1145470468.10144.0.camel@resist.wooz.org> On Wed, 2006-04-19 at 10:44 -0500, William McVey wrote: > The current status of the patch is that it has been assigned to Barry > Warsaw, but no (visible) activity seems to have occurred since the > ticket was assigned. I was hoping this patch could get integrated into > the upcoming python 2.5. The fix is fairly important to me as I now > manage my incoming mail using python and I'm on lists with individuals > who tend to like the (( )) construct. I'm hoping this email nudges the > process forward a bit and doesn't offend anyone for the out-of-band > reminder. Nope, thanks for the reminder. I'll try to take a look at it over the next day or two. -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 309 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/email-sig/attachments/20060419/9a87baaf/attachment.pgp From barry at python.org Sun Apr 30 23:28:43 2006 From: barry at python.org (Barry Warsaw) Date: Sun, 30 Apr 2006 17:28:43 -0400 Subject: [Email-SIG] Python patch submittion 1464708 In-Reply-To: <1145461496.9715.21.camel@tardis.cisco.com> References: <1145461496.9715.21.camel@tardis.cisco.com> Message-ID: <1146432523.2269.20.camel@resist.wooz.org> On Wed, 2006-04-19 at 10:44 -0500, William McVey wrote: > A couple weeks ago I submitted patch 1464708 > (https://sourceforge.net/tracker/index.php?func=detail&aid=1464708&group_id=5470&atid=305470) which fixes the parsing of email addresses in the 'email' and 'rfc822' packages. This fix is critical in handling addresses of the form: This has now been applied to the Python 2.4 branch for email 3.0. I will forward port it to Python 2.5 for email 4.0 and back port it to Python 2.3 for email 2.5. -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 309 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/email-sig/attachments/20060430/60335f75/attachment.pgp