Re: html email function to a large recipient list problem

2014-05-13 Thread Venkatraman S
I havent looked at your entire problem statement , but
https://github.com/pinax/django-mailer does give you many features w.r.t
emails OOB.


On Mon, May 12, 2014 at 3:49 PM, MikeKJ  wrote:

> Anyone have an insight into this please?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1bbb2ae1-1964-4ee0-9872-d59391dcd33e%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7tdFQ1%3DVt7LqrKGgTraUFsJAm2TJX-11u-d-i%3DfjHtgiLLEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: html email function to a large recipient list problem

2014-05-12 Thread MikeKJ
Anyone have an insight into this please?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1bbb2ae1-1964-4ee0-9872-d59391dcd33e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


html email function to a large recipient list problem

2014-05-07 Thread MikeKJ
I have these functions to send update emails to a subscriber list 
(recipients) but for some reason I cannot seem to fathom it does:

Connect
Send Email A
Connect 
Connect
Send Email B
Send Email B
Connect 
Connect
Connect
Send Email C
Send Email C
Send Email C

etc etc

Can anyone see where the incrementing is happening because I can't.
Interestingly it seems that even though the logger says each email is sent 
multiple (by increment, like the 1000th address on the list theoretically 
should get the same email 1000 times) it doesnt, just the one email or so 
it appears, if anyone has an explanation for that as well I would be 
interested


def send( self ):
c = Context({ "content": self.introductory_text, "user":None, 
"request":None, "updates": [] })
t = loader.get_template('emailer/html/updates.html')
subject = self.subject
recipients = []
if self.to_all_principal_contacts:
for gs in GroupSubscription.objects.all():
if not gs in self.recipients.all():
self.recipients.add( gs.principal_contact.id )
for i in self.recipients.all():
i.save()
super( UpdateEmail, self ).save()

if self.to_all_subscribers:
for subscriber in 
UserProfile.objects.select_related().order_by('name'):
if subscriber.subscription_set.count() > 0:
if not subscriber in self.recipients.all():
self.recipients.add(subscriber)
for i in self.recipients.all():
i.save()
super( UpdateEmail, self ).save()

for i in self.recipients.all():
recipients.append( i.email )
#  raise NameError(recipients) #This produces a list of singlular email 
addresses not incremented
self.save()
html = t.render(c)
#  raise NameError(html) #as expected this si just the html of the 
content
#  x = []
for i in recipients:
#x.append(i)
send_html_email( subject, html, "upda...@domain.co.uk", i, 
image_root=settings.PROJECT_DIR )
from datetime import datetime
self.sent_on = datetime.now()
self.sent = True
self.save()
#  raise NameError(x) #This produces a list of singlular email 
addresses not incremented




def send_html_email(subject_line, html_content, from_address, to_address, 
text_content=None, image_root=None, attachments=[]):
"""
Send an html email, which can have embedded images.
from_address can look like 'some...@somewhere.net',
or 'Some dude '.
to_addresses needs to be a list of such addresses.
Image hrefs need to be like /media/image1.gif. image_root needs to be 
the
prefix to allow us to find those images on the filesystem
attachments should be a list of dicts with 'mimetype', 'filename' and 
'payload' keys
"""
parser = EmailConverter()
parser.feed(html_content.encode('utf-8'))
text_content = text_content or 
strip_html_for_email(html_content.encode("utf-8"))

msgRoot = MIMEMultipart('related')
msgRoot['Subject'] = subject_line
msgRoot['From'] = from_address
msgRoot['To'] = to_address
msgRoot.preamble = 'This is a multi-part message in MIME format.'

msgAlternative = MIMEMultipart('alternative')
msgRoot.attach(msgAlternative)

msgAlternative.attach(MIMEText(text_content))
msgAlternative.attach(MIMEText(parser.body, 'html'))

for img in parser.imagelist:
fp = open(image_root+img[1], 'rb')
msgImg = MIMEImage(fp.read())
fp.close()
msgImg.add_header('Content-ID', '' % img[0])
msgRoot.attach(msgImg)

for attachment in attachments:
mimetype_bits = attachment['mimetype'].split('/')
a = MIMEBase(mimetype_bits[0], mimetype_bits[1])
a.set_payload(attachment['payload'])
Encoders.encode_base64(a)
a.add_header('Content-Disposition', 'attachment; filename="%s"' % 
attachment['filename'])
msgRoot.attach(a)

smtp = smtplib.SMTP()
from django.conf import settings
smtp.connect(settings.EMAIL_HOST, settings.EMAIL_PORT )
smtp.login( settings.EMAIL_HOST_USER, settings.EMAIL_HOST_PASSWORD )
logger = getlogger()
logger.info("Connected to %s on port %s as %s" % (settings.EMAIL_HOST, 
settings.EMAIL_PORT, settings.EMAIL_HOST_USER) )
import sys

try:
smtp.sendmail(from_address, to_address, msgRoot.as_string())
logger.info("Successfully sent %s -> %s" % ( from_address, 
to_address ))
except:
logger.info("Unexpected er

Re: Embedding multiple images in html email

2009-10-15 Thread Tim Chase

> Can't you include the link and source within the html code of the email?

The problem then becomes that many email programs no longer 
display remote images inline unless the email comes from a 
trusted source.  It was a popular way to add tracking bugs to 
HTML emails, so MUAs began to disable the functionality.  To get 
around it, you have to include the image in the HTML-email itself 
as a named attachment, and then reference it with  as described at[1]

Don't forget that some folks fly with HTML email turned off or 
from mobile devices that may not support HTML email, so they will 
only see the plain-text version which you'll want to include. 
The images and HTML version will likely appear merely as attachments.

-tim

[1]
http://code.activestate.com/recipes/473810/




--~--~-~--~~~---~--~~
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: Embedding multiple images in html email

2009-10-15 Thread Angel Cruz
Can't you include the link and source within the html code of the email?

for example, as a snippet:
.
.
.
html = """\

  
  blah blah blah
   
http://blah-blah-blah.com";>http://blah-blah-blah.com/media/img/blah-blah-whatver-image.png";
width=100%>

Blah-whatever-your-message-here




"""

# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')

# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this
case
# the HTML message, is best and preferred.
msg.attach(part1)
msg.attach(part2)

s = smtplib.SMTP(blah-blah-whatever-MY_SMTP_SERVER)
# sendmail function takes 3 arguments: sender's address, recipient's
address
# and message to send - here it is sent as one string.
s.sendmail(me, myRecipient, msg.as_string())
s.quit()
.
.
.

Since it is html, you can embed as many images as you want?

On Thu, Oct 15, 2009 at 5:30 AM, Muhammed Abad wrote:

>
> As the topic says, can I embed multiple images in an html email
> template so the recipient does not have to download them?
>
> I know this might be a silly request, but a client has asked me to do
> this for him and Im absolutely stumped.
>
> The closest to a solution I have come to is this :
> http://www.djangosnippets.org/snippets/1507/
>
> If someone else can get this to work, please let me know.
>
> Any other solution are welcome.
>
> Thanks in advance.
>
> M.
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Embedding multiple images in html email

2009-10-15 Thread Muhammed Abad

As the topic says, can I embed multiple images in an html email
template so the recipient does not have to download them?

I know this might be a silly request, but a client has asked me to do
this for him and Im absolutely stumped.

The closest to a solution I have come to is this :
http://www.djangosnippets.org/snippets/1507/

If someone else can get this to work, please let me know.

Any other solution are welcome.

Thanks in advance.

M.

--~--~-~--~~~---~--~~
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 do I add my template content to my html email?

2009-01-10 Thread alex.gay...@gmail.com

You can create  a template and render it the same way you would in a
view, checkout the render_to_string function(it's in django.template I
believe).

Alex

On Jan 10, 2:41 pm, Michael  wrote:
> Hello,
> I able to send an html email using the code below:
>
> ///
>
> def emaildiscount(request):
>     subject, from_email, to = 'hello', 'u...@domain.com',
> 'u...@domain.com'
>     text_content = 'This is an important message.'
>     html_content = 'This is an important message. p>'
>     msg = EmailMultiAlternatives(subject, text_content, from_email,
> [to])
>     msg.attach_alternative(html_content, "text/html")
>     msg.send()
>
> ///
>
> However, I've now created a .htm file that I want to use as the email
> content.  The .htm template is over 100 lines long.  I don't think
> pasting the code into the view is the smart thing to do.  Does django
> allow the html_content variable to access my .htm file?
>
> Thanks
--~--~-~--~~~---~--~~
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 do I add my template content to my html email?

2009-01-10 Thread Michael

Hello,
I able to send an html email using the code below:

///

def emaildiscount(request):
subject, from_email, to = 'hello', 'u...@domain.com',
'u...@domain.com'
text_content = 'This is an important message.'
html_content = 'This is an important message.'
msg = EmailMultiAlternatives(subject, text_content, from_email,
[to])
msg.attach_alternative(html_content, "text/html")
msg.send()

///

However, I've now created a .htm file that I want to use as the email
content.  The .htm template is over 100 lines long.  I don't think
pasting the code into the view is the smart thing to do.  Does django
allow the html_content variable to access my .htm file?

Thanks


--~--~-~--~~~---~--~~
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: Sending HTML email

2008-09-23 Thread Berco Beute

> You might try reading the 
> documentation:http://docs.djangoproject.com/en/dev/topics/email/#sending-alternativ...

Oops, completely overlooked that. Thanks for the pointer.

2B
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sending HTML email

2008-09-23 Thread Matthias Kestenholz

On Tue, Sep 23, 2008 at 7:38 PM, Berco Beute <[EMAIL PROTECTED]> wrote:
>
> Currently I'm sending plain text mails using:
>
> ###
> from django.core.mail import EmailMessage
> email = EmailMessage('hi', 'howdy', host, to)
> email.send()
> ###
>
> But now I want to use HTML in the body of the email. How do I format
> such a message and can I just send it like above?
>

Yes, or at least in a similar way. You might try reading the documentation:
http://docs.djangoproject.com/en/dev/topics/email/#sending-alternative-content-types

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sending HTML email

2008-09-23 Thread Jeff Gentry


On Tue, 23 Sep 2008, Berco Beute wrote:
> But now I want to use HTML in the body of the email. How do I format
> such a message and can I just send it like above?

Emails should be plain text, not HTML ;)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Sending HTML email

2008-09-23 Thread Berco Beute

Currently I'm sending plain text mails using:

###
from django.core.mail import EmailMessage
email = EmailMessage('hi', 'howdy', host, to)
email.send()
###

But now I want to use HTML in the body of the email. How do I format
such a message and can I just send it like above?

2B
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: HTML Email

2008-07-02 Thread Peter Melvyn

On 7/3/08, Bobby Roberts <[EMAIL PROTECTED]> wrote:

> is there a way in Django to send an actual HTML email?  I can only get
> it to send as an attachment to a text email which is really pointless
> in my opinion.

Did you read paragraph "Sending alternative content types" in
http://www.djangoproject.com/documentation/email/

Peter

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: HTML Email

2008-07-02 Thread Julien

Hi,

Sending HTML as an attachment means that the HTML version will be
displayed by email client that are configured so, including all the
web-based clients like GMail. Clients that can't show HTML or are
configured not to show HTML will show the text version instead.

This is therefore best practice and the recommended way to go.

Cheers,

Julien

On Jul 3, 2:03 pm, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> is there a way in Django to send an actual HTML email?  I can only get
> it to send as an attachment to a text email which is really pointless
> in my opinion.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



HTML Email

2008-07-02 Thread Bobby Roberts

is there a way in Django to send an actual HTML email?  I can only get
it to send as an attachment to a text email which is really pointless
in my opinion.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sending an html email

2006-08-27 Thread [EMAIL PROTECTED]

> I am using the template to build the email content.  I included links
> in it but the email are sent in plain text, not in html.  What is the
> way to go to send html email ?  Eventually, i'd like to add images too.

Hi Rem,

I got this one off the cookbook a while back. You'll have to call it
after render, and it will return a text object suitable for sending.

import cStringIO, MimeWriter, mimetools

def createhtmlmail(subject, html, text=""):
"""Create a mime-message that will render HTML in popular
MUAs, text in better ones"""

out = cStringIO.StringIO() # output buffer for our message
htmlin = cStringIO.StringIO(html)

writer = MimeWriter.MimeWriter(out)
writer.addheader("Subject", subject)
writer.addheader("MIME-Version", "1.0")
writer.startmultipartbody("alternative")
writer.flushheaders()

#
# the plain text section
#
if text:
txtin = cStringIO.StringIO(text)
subpart = writer.nextpart()
subpart.addheader("Content-Transfer-Encoding",
"quoted-printable")
pout = subpart.startbody("text/plain", [("charset",
'us-ascii')])
mimetools.encode(txtin, pout, 'quoted-printable')
txtin.close()

#
# start the html subpart of the message
#
subpart = writer.nextpart()
subpart.addheader("Content-Transfer-Encoding", "quoted-printable")
pout = subpart.startbody("text/html", [("charset", 'us-ascii')])
mimetools.encode(htmlin, pout, 'quoted-printable')
htmlin.close()
writer.lastpart()
msg = out.getvalue()
out.close()
#print msg
return msg

hth,
-- bjorn


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Sending an html email

2006-08-27 Thread Corey Oordt
I've never done it before, but here are some places to look:http://code.djangoproject.com/ticket/1541http://www.rossp.org/blog/2006/jul/11/sending-e-mails-templates/CoreyOn Aug 26, 2006, at 8:59 PM, The Rem wrote:Hi,I am using the template to build the email content.  I included linksin it but the email are sent in plain text, not in html.  What is theway to go to send html email ?  Eventually, i'd like to add images too.Thanks in advance for your helpRem

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---


Sending an html email

2006-08-26 Thread The Rem

Hi,

I am using the template to build the email content.  I included links
in it but the email are sent in plain text, not in html.  What is the
way to go to send html email ?  Eventually, i'd like to add images too.
 

Thanks in advance for your help

Rem


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---