4
4
from blog .models import Article
5
5
from django .core .mail import EmailMultiAlternatives
6
6
from django .contrib .sites .models import Site
7
+ import _thread
7
8
8
9
9
10
# Create your models here.
@@ -24,6 +25,9 @@ class Meta:
24
25
verbose_name = "评论"
25
26
verbose_name_plural = verbose_name
26
27
28
+ def send_comment_email (self , msg ):
29
+ msg .send ()
30
+
27
31
def save (self , * args , ** kwargs ):
28
32
super ().save (* args , ** kwargs )
29
33
subject = '感谢您发表的评论'
@@ -43,8 +47,8 @@ def save(self, *args, **kwargs):
43
47
msg = EmailMultiAlternatives (subject , html_content , from_email = 'no-reply@lylinux.net' , to = [tomail ])
44
48
45
49
msg .content_subtype = "html"
50
+ _thread .start_new_thread (self .send_comment_email , (msg ))
46
51
47
- result = msg .send ()
48
52
if self .parent_comment :
49
53
html_content = """
50
54
您在 <a href="%s" rel="bookmark">%s</a> 的评论 <br/> %s <br/> 收到回复啦.快去看看吧
@@ -55,7 +59,7 @@ def save(self, *args, **kwargs):
55
59
tomail = self .parent_comment .author .email
56
60
msg = EmailMultiAlternatives (subject , html_content , from_email = 'no-reply@lylinux.net' , to = [tomail ])
57
61
msg .content_subtype = "html"
58
- result = msg . send ( )
62
+ _thread . start_new_thread ( self . send_comment_email , ( msg ) )
59
63
60
64
def __str__ (self ):
61
65
return self .body
0 commit comments