On Saturday, June 30, 2012, Ram Rachum wrote:
> Hi everyone,
> Is there a package that is to email what `requests` is to HTTP?
> Thanks,
> Ram.
> --
> You received this message because you are subscribed to the Google Groups
> "PyWeb-IL" group.
> To post to this group, send email to pyweb-il@googlegroups.com<javascript:_e({}, 'cvml', 'pyweb-il@googlegroups.com');>
> .
> To unsubscribe from this group, send email to
> pyweb-il+unsubscribe@googlegroups.com <javascript:_e({}, 'cvml',
> 'pyweb-il%2Bunsubscribe@googlegroups.com');>.
> For more options, visit this group at
> http://groups.google.com/group/pyweb-il?hl=en.
Under "First, let’s see how to create and send a simple text message"
I don't know whether this should be considered sad or funny. That example
code does everything except licking a stamp in order to put it on the
email. This is the exact opposite of what I'm looking for :)
> (from the author of "requests")
> But again, you should probably be more specific..
> Oz
> On Saturday, June 30, 2012, Ram Rachum wrote:
>> Hi everyone,
>> Is there a package that is to email what `requests` is to HTTP?
>> Thanks,
>> Ram.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PyWeb-IL" group.
>> To post to this group, send email to pyweb-il@googlegroups.com.
>> To unsubscribe from this group, send email to
>> pyweb-il+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/pyweb-il?hl=en.
> --
> You received this message because you are subscribed to the Google Groups
> "PyWeb-IL" group.
> To post to this group, send email to pyweb-il@googlegroups.com.
> To unsubscribe from this group, send email to
> pyweb-il+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyweb-il?hl=en.
> I basically want a function `send_mail` that takes an email address, a
> subject line, and a content, and sends.
email doesn't work this way. You need a sender, and most mail servers for receivers will not talk to you if you don't have an MX record in DNS; which means, in practice, you need some "recognized" mail server to send through.
So, your "send mail" function can only work after you've told it, in some way, who's the sender, where's the mail server, and (usually) how to log in to it.
> I know that Django provides one, but using Django would entail having a
> "site" and a settings file, and I don't want any of those for this project.
The little email I did out of Django was using Lamson (lamsonproject.org) -- but again, that is more on the receiving end, and it's a whole framework. Perhaps you can get something more to your taste out of that.
On Sat, Jun 30, 2012 at 11:05 PM, Shai Berger <s...@platonix.com> wrote:
> On Saturday 30 June 2012, Ram Rachum wrote:
> > I basically want a function `send_mail` that takes an email address, a
> > subject line, and a content, and sends.
> email doesn't work this way. You need a sender, and most mail servers for
> receivers will not talk to you if you don't have an MX record in DNS; which
> means, in practice, you need some "recognized" mail server to send through.
> So, your "send mail" function can only work after you've told it, in some
> way,
> who's the sender, where's the mail server, and (usually) how to log in to
> it.
Sorry, I should have specified that I'm okay with specifying SMTP settings.
So: Import, specify STMP settings, send mail. Anything that does that?
Basically my approach is "simple things should be simple, complex things
should be possible." I want a package that makes the basic tasks as simple
as possible, without even having to read the documentation beyond the
"quick examples" section, and people who have more complex needs could dig
in to the documentation and the code, instantiate classes and call their
methods, etc.
> > I know that Django provides one, but using Django would entail having a
> > "site" and a settings file, and I don't want any of those for this
> project.
> The little email I did out of Django was using Lamson (lamsonproject.org)
> --
> but again, that is more on the receiving end, and it's a whole framework.
> Perhaps you can get something more to your taste out of that.
> HTH,
> Shai.
> --
> You received this message because you are subscribed to the Google Groups
> "PyWeb-IL" group.
> To post to this group, send email to pyweb-il@googlegroups.com.
> To unsubscribe from this group, send email to
> pyweb-il+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyweb-il?hl=en.
> Sorry, I should have specified that I'm okay with specifying SMTP
> settings. So: Import, specify STMP settings, send mail. Anything that does
> that?
Yeah, the Django builtin send_mail(). I'm not sure why you think it's
complicated.
It's almost good enough, the problem is that you need to have a Django
settings file.
Let me give you an example of usage, of something I wanted to do today.
Today, as many of you have probably noticed, half the Internet was down due
to electrical storms in the East Coast. Okay, not really half, but many big
sites. (Heroku, AWS, Pinterest, NetFlix...)
Our website was one of the casualties. It was down, and I wanted to write a
short Python script that would try to visit it every 2 minutes, and when it
finally succeeds, shoot me a mail telling me the site is back up.
Now, that script is so simple, I intended to write it in the REPL, not even
saving it to a file, and just keep it running in a `screen` session.
On Sun, Jul 1, 2012 at 12:31 AM, Yuval Adam <yuv....@gmail.com> wrote:
> Sorry, I should have specified that I'm okay with specifying SMTP
>> settings. So: Import, specify STMP settings, send mail. Anything that does
>> that?
> Yeah, the Django builtin send_mail(). I'm not sure why you think it's
> complicated.
> --
> You received this message because you are subscribed to the Google Groups
> "PyWeb-IL" group.
> To post to this group, send email to pyweb-il@googlegroups.com.
> To unsubscribe from this group, send email to
> pyweb-il+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyweb-il?hl=en.
On Sun, Jul 1, 2012 at 12:52 AM, Ram Rachum <r...@rachum.com> wrote:
> It's almost good enough, the problem is that you need to have a Django
> settings file.
> Let me give you an example of usage, of something I wanted to do today.
> Today, as many of you have probably noticed, half the Internet was down
> due to electrical storms in the East Coast. Okay, not really half, but many
> big sites. (Heroku, AWS, Pinterest, NetFlix...)
> Our website was one of the casualties. It was down, and I wanted to write
> a short Python script that would try to visit it every 2 minutes, and when
> it finally succeeds, shoot me a mail telling me the site is back up.
> Now, that script is so simple, I intended to write it in the REPL, not
> even saving it to a file, and just keep it running in a `screen` session.
> I wanted something to the effect of:
> >>> while 'Error' in requests.get('http://oursite.com').content: > ... time.sleep(120)
> ... send_mail('...@rachum.com', 'Site is back up!')
> Now, if I had to introduce a Django `settings.py` file into this, it would
> have been a lot more cumbersome.
> On Sun, Jul 1, 2012 at 12:31 AM, Yuval Adam <yuv....@gmail.com> wrote:
>> Sorry, I should have specified that I'm okay with specifying SMTP
>>> settings. So: Import, specify STMP settings, send mail. Anything that does
>>> that?
>> Yeah, the Django builtin send_mail(). I'm not sure why you think it's
>> complicated.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PyWeb-IL" group.
>> To post to this group, send email to pyweb-il@googlegroups.com.
>> To unsubscribe from this group, send email to
>> pyweb-il+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/pyweb-il?hl=en.
> --
> You received this message because you are subscribed to the Google Groups
> "PyWeb-IL" group.
> To post to this group, send email to pyweb-il@googlegroups.com.
> To unsubscribe from this group, send email to
> pyweb-il+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyweb-il?hl=en.
Ignore the `raw_input` parts which take the bulk of the example, but look
at the construction of `msg`. You have to add the `From` and `To` headers
manually in the text. Lame.
And actually a bigger issue: You need to authenticate to the SMTP server,
and that's a separate line, calling `SMTP.login`.
On Sun, Jul 1, 2012 at 1:06 AM, Yuval Adam <yuv....@gmail.com> wrote:
> Well, as far as I remember the smtplib API is reasonable.
> Something along the lines:
> Don't copy-paste, obviously, but real use shouldn't be much different.
> Though I definitely agree it would be nice to see an SMTP equivalent for
> requests.
> On Sun, Jul 1, 2012 at 12:52 AM, Ram Rachum <r...@rachum.com> wrote:
>> It's almost good enough, the problem is that you need to have a Django
>> settings file.
>> Let me give you an example of usage, of something I wanted to do today.
>> Today, as many of you have probably noticed, half the Internet was down
>> due to electrical storms in the East Coast. Okay, not really half, but many
>> big sites. (Heroku, AWS, Pinterest, NetFlix...)
>> Our website was one of the casualties. It was down, and I wanted to write
>> a short Python script that would try to visit it every 2 minutes, and when
>> it finally succeeds, shoot me a mail telling me the site is back up.
>> Now, that script is so simple, I intended to write it in the REPL, not
>> even saving it to a file, and just keep it running in a `screen` session.
>> I wanted something to the effect of:
>> >>> while 'Error' in requests.get('http://oursite.com').content: >> ... time.sleep(120)
>> ... send_mail('...@rachum.com', 'Site is back up!')
>> Now, if I had to introduce a Django `settings.py` file into this, it
>> would have been a lot more cumbersome.
>> On Sun, Jul 1, 2012 at 12:31 AM, Yuval Adam <yuv....@gmail.com> wrote:
>>> Sorry, I should have specified that I'm okay with specifying SMTP
>>>> settings. So: Import, specify STMP settings, send mail. Anything that does
>>>> that?
>>> Yeah, the Django builtin send_mail(). I'm not sure why you think it's
>>> complicated.
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "PyWeb-IL" group.
>>> To post to this group, send email to pyweb-il@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> pyweb-il+unsubscribe@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/pyweb-il?hl=en.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PyWeb-IL" group.
>> To post to this group, send email to pyweb-il@googlegroups.com.
>> To unsubscribe from this group, send email to
>> pyweb-il+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/pyweb-il?hl=en.
> --
> You received this message because you are subscribed to the Google Groups
> "PyWeb-IL" group.
> To post to this group, send email to pyweb-il@googlegroups.com.
> To unsubscribe from this group, send email to
> pyweb-il+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyweb-il?hl=en.
On Sun, Jul 1, 2012 at 1:23 AM, Ram Rachum <r...@rachum.com> wrote:
> I was almost convinced that `smtplib` is good enough, but then I saw the
> example here:
> Ignore the `raw_input` parts which take the bulk of the example, but look
> at the construction of `msg`. You have to add the `From` and `To` headers
> manually in the text. Lame.
> And actually a bigger issue: You need to authenticate to the SMTP server,
> and that's a separate line, calling `SMTP.login`.
> On Sun, Jul 1, 2012 at 1:06 AM, Yuval Adam <yuv....@gmail.com> wrote:
>> Well, as far as I remember the smtplib API is reasonable.
>> Something along the lines:
>> Don't copy-paste, obviously, but real use shouldn't be much different.
>> Though I definitely agree it would be nice to see an SMTP equivalent for
>> requests.
>> On Sun, Jul 1, 2012 at 12:52 AM, Ram Rachum <r...@rachum.com> wrote:
>>> It's almost good enough, the problem is that you need to have a Django
>>> settings file.
>>> Let me give you an example of usage, of something I wanted to do today.
>>> Today, as many of you have probably noticed, half the Internet was down
>>> due to electrical storms in the East Coast. Okay, not really half, but many
>>> big sites. (Heroku, AWS, Pinterest, NetFlix...)
>>> Our website was one of the casualties. It was down, and I wanted to
>>> write a short Python script that would try to visit it every 2 minutes, and
>>> when it finally succeeds, shoot me a mail telling me the site is back up.
>>> Now, that script is so simple, I intended to write it in the REPL, not
>>> even saving it to a file, and just keep it running in a `screen` session.
>>> I wanted something to the effect of:
>>> >>> while 'Error' in requests.get('http://oursite.com').content: >>> ... time.sleep(120)
>>> ... send_mail('...@rachum.com', 'Site is back up!')
>>> Now, if I had to introduce a Django `settings.py` file into this, it
>>> would have been a lot more cumbersome.
>>> On Sun, Jul 1, 2012 at 12:31 AM, Yuval Adam <yuv....@gmail.com> wrote:
>>>> Sorry, I should have specified that I'm okay with specifying SMTP
>>>>> settings. So: Import, specify STMP settings, send mail. Anything that does
>>>>> that?
>>>> Yeah, the Django builtin send_mail(). I'm not sure why you think it's
>>>> complicated.
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "PyWeb-IL" group.
>>>> To post to this group, send email to pyweb-il@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> pyweb-il+unsubscribe@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/pyweb-il?hl=en.
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "PyWeb-IL" group.
>>> To post to this group, send email to pyweb-il@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> pyweb-il+unsubscribe@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/pyweb-il?hl=en.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PyWeb-IL" group.
>> To post to this group, send email to pyweb-il@googlegroups.com.
>> To unsubscribe from this group, send email to
>> pyweb-il+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/pyweb-il?hl=en.
On Wed, Jul 4, 2012 at 11:26 AM, Ram Rachum <r...@rachum.com> wrote:
> Attached is the makeshift module I made for myself now. It's very very
> basic. This way I could send email to myself in simple scripts.
> To use it, replace 'your.auxiliary.em...@gmail.com', 'your.auxiliary.password'
> and 'your.r...@email.com' with real values.
> Hope this is useful for someone.
> On Sun, Jul 1, 2012 at 1:23 AM, Ram Rachum <r...@rachum.com> wrote:
>> I was almost convinced that `smtplib` is good enough, but then I saw the
>> example here:
>> Ignore the `raw_input` parts which take the bulk of the example, but look
>> at the construction of `msg`. You have to add the `From` and `To` headers
>> manually in the text. Lame.
>> And actually a bigger issue: You need to authenticate to the SMTP server,
>> and that's a separate line, calling `SMTP.login`.
>> On Sun, Jul 1, 2012 at 1:06 AM, Yuval Adam <yuv....@gmail.com> wrote:
>>> Well, as far as I remember the smtplib API is reasonable.
>>> Something along the lines:
>>> Don't copy-paste, obviously, but real use shouldn't be much different.
>>> Though I definitely agree it would be nice to see an SMTP equivalent for
>>> requests.
>>> On Sun, Jul 1, 2012 at 12:52 AM, Ram Rachum <r...@rachum.com> wrote:
>>>> It's almost good enough, the problem is that you need to have a Django
>>>> settings file.
>>>> Let me give you an example of usage, of something I wanted to do today.
>>>> Today, as many of you have probably noticed, half the Internet was down
>>>> due to electrical storms in the East Coast. Okay, not really half, but many
>>>> big sites. (Heroku, AWS, Pinterest, NetFlix...)
>>>> Our website was one of the casualties. It was down, and I wanted to
>>>> write a short Python script that would try to visit it every 2 minutes, and
>>>> when it finally succeeds, shoot me a mail telling me the site is back up.
>>>> Now, that script is so simple, I intended to write it in the REPL, not
>>>> even saving it to a file, and just keep it running in a `screen` session.
>>>> I wanted something to the effect of:
>>>> >>> while 'Error' in requests.get('http://oursite.com').content: >>>> ... time.sleep(120)
>>>> ... send_mail('...@rachum.com', 'Site is back up!')
>>>> Now, if I had to introduce a Django `settings.py` file into this, it
>>>> would have been a lot more cumbersome.
>>>> On Sun, Jul 1, 2012 at 12:31 AM, Yuval Adam <yuv....@gmail.com> wrote:
>>>>> Sorry, I should have specified that I'm okay with specifying SMTP
>>>>>> settings. So: Import, specify STMP settings, send mail. Anything that does
>>>>>> that?
>>>>> Yeah, the Django builtin send_mail(). I'm not sure why you think it's
>>>>> complicated.
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "PyWeb-IL" group.
>>>>> To post to this group, send email to pyweb-il@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> pyweb-il+unsubscribe@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/pyweb-il?hl=en.
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "PyWeb-IL" group.
>>>> To post to this group, send email to pyweb-il@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> pyweb-il+unsubscribe@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/pyweb-il?hl=en.
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "PyWeb-IL" group.
>>> To post to this group, send email to pyweb-il@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> pyweb-il+unsubscribe@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/pyweb-il?hl=en.
> --
> You received this message because you are subscribed to the Google Groups
> "PyWeb-IL" group.
> To post to this group, send email to pyweb-il@googlegroups.com.
> To unsubscribe from this group, send email to
> pyweb-il+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyweb-il?hl=en.