Re: How to create ability to send email from the admin with django?

2009-04-03 Thread TiNo
On Thu, Apr 2, 2009 at 5:42 PM, ChrisR  wrote:

> Where is that code supposed to live?  How do you actually send it?
> I've seen a few things that imply you did it from the Python API?
>

Probably the easiest thing to do is create an admin action for it [1]. I
just recently wrote this, so here is (snippets of) my code [2].

The send_mail method does exactly as it says, it sends mail with subject,
message, from, to some recepients.

TiNo

[1]
http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#ref-contrib-admin-actions
[2] http://dpaste.com/22969/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to create ability to send email from the admin with django?

2009-04-02 Thread Timboy

In two lines:

from django.core.mail import send_mail

send_mail('Subject here', 'Here is the message.', 'f...@example.com',
['t...@example.com'], fail_silently=False)

Mail is sent using the SMTP host and port specified in the EMAIL_HOST
and EMAIL_PORT settings. The EMAIL_HOST_USER and EMAIL_HOST_PASSWORD
settings, if set, are used to authenticate to the SMTP server, and the
EMAIL_USE_TLS setting controls whether a secure connection is used.

On Apr 2, 8:42 am, ChrisR  wrote:
> I've been searching and trying to figure this out, but I haven't quite
> found the source that makes it snap in my mind.
>
> I'd like to be able to send an email or emails out from my site
> through the admin.  I have the email settings added to settings.py,
> but not sure where to go next.
>
> I've read the documentation about sending email on the django 
> site:http://docs.djangoproject.com/en/1.0/topics/email/
>
> The "Quick" example that allows you to send email in 2 lines doesn't
> make sense to me:
> "from django.core.mail import send_mail
>
> send_mail('Subject here', 'Here is the message.', 'f...@example.com',
>     ['@example.com'], fail_silently=False)"
>
> Where is that code supposed to live?  How do you actually send it?
> I've seen a few things that imply you did it from the Python API?
>
> Can someone point me in the right direction on how to make this happen
> through the admin?  Do I need to make a model for it?  What triggers
> the actual send then?
>
> Thanks for any help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to create ability to send email from the admin with django?

2009-04-02 Thread ChrisR

I've been searching and trying to figure this out, but I haven't quite
found the source that makes it snap in my mind.

I'd like to be able to send an email or emails out from my site
through the admin.  I have the email settings added to settings.py,
but not sure where to go next.

I've read the documentation about sending email on the django site:
http://docs.djangoproject.com/en/1.0/topics/email/

The "Quick" example that allows you to send email in 2 lines doesn't
make sense to me:
"from django.core.mail import send_mail

send_mail('Subject here', 'Here is the message.', 'f...@example.com',
['t...@example.com'], fail_silently=False)"


Where is that code supposed to live?  How do you actually send it?
I've seen a few things that imply you did it from the Python API?

Can someone point me in the right direction on how to make this happen
through the admin?  Do I need to make a model for it?  What triggers
the actual send then?

Thanks for any help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to create ability to send email from the admin with django?

2009-04-02 Thread ChrisR

I've been searching and trying to figure this out, but I haven't quite
found the source that makes it snap in my mind.

I'd like to be able to send an email or emails out from my site
through the admin.  I have the email settings added to settings.py,
but not sure where to go next.

I've read the documentation about sending email on the django site:
http://docs.djangoproject.com/en/1.0/topics/email/

The "Quick" example that allows you to send email in 2 lines doesn't
make sense to me:
"from django.core.mail import send_mail

send_mail('Subject here', 'Here is the message.', 'f...@example.com',
['t...@example.com'], fail_silently=False)"


Where is that code supposed to live?  How do you actually send it?
I've seen a few things that imply you did it from the Python API?

Can someone point me in the right direction on how to make this happen
through the admin?  Do I need to make a model for it?  What triggers
the actual send then?

Thanks for any help!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---