| Line 38... |
Line 38... |
| 38 |
self._textBody = None
|
38 |
self._textBody = None
|
| 39 |
self._htmlBody = None
|
39 |
self._htmlBody = None
|
| 40 |
self._subject = ""
|
40 |
self._subject = ""
|
| 41 |
self._smtpServer = smtpServer
|
41 |
self._smtpServer = smtpServer
|
| 42 |
self._reEmail = re.compile("^([\\w \\._]+\\<[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\>|[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)$")
|
42 |
self._reEmail = re.compile("^([\\w \\._]+\\<[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\>|[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)$")
|
| - |
|
43 |
self._bcc = ['manish.sharma@shop2020.in']
|
| 43 |
self.clearRecipients()
|
44 |
self.clearRecipients()
|
| 44 |
self.clearAttachments()
|
45 |
self.clearAttachments()
|
| 45 |
|
46 |
|
| 46 |
def send(self):
|
47 |
def send(self):
|
| 47 |
"""
|
48 |
"""
|
| Line 108... |
Line 109... |
| 108 |
msg.attach(attach)
|
109 |
msg.attach(attach)
|
| 109 |
# Some header stuff
|
110 |
# Some header stuff
|
| 110 |
msg['Subject'] = self._subject
|
111 |
msg['Subject'] = self._subject
|
| 111 |
msg['From'] = self._from
|
112 |
msg['From'] = self._from
|
| 112 |
msg['To'] = ", ".join(self._to)
|
113 |
msg['To'] = ", ".join(self._to)
|
| - |
|
114 |
msg['Bcc'] = ", ".join(self._bcc)
|
| 113 |
msg.preamble = "You need a MIME enabled mail reader to see this message"
|
115 |
msg.preamble = "You need a MIME enabled mail reader to see this message"
|
| 114 |
# Send message
|
116 |
# Send message
|
| 115 |
msg = msg.as_string()
|
117 |
msg = msg.as_string()
|
| 116 |
server = smtplib.SMTP(self._smtpServer)
|
118 |
server = smtplib.SMTP(self._smtpServer)
|
| 117 |
server.sendmail(self._from, self._to, msg)
|
119 |
server.sendmail(self._from, self._to, msg)
|
| Line 199... |
Line 201... |
| 199 |
previousDay = datetime.datetime(currentTime.year,currentTime.month, currentTime.day, 0, 0)- timedelta(days=1)
|
201 |
previousDay = datetime.datetime(currentTime.year,currentTime.month, currentTime.day, 0, 0)- timedelta(days=1)
|
| 200 |
mTo = session.query(Users.email).filter(Users.mobile_number == None).filter(Users.created >= previousDay).all()
|
202 |
mTo = session.query(Users.email).filter(Users.mobile_number == None).filter(Users.created >= previousDay).all()
|
| 201 |
#mTo = ["manish.sharma@shop2020.in", "manas.kapoor@shop2020.in"]
|
203 |
#mTo = ["manish.sharma@shop2020.in", "manas.kapoor@shop2020.in"]
|
| 202 |
mFrom = "ProfitMandi<help@profitmandi.com>"
|
204 |
mFrom = "ProfitMandi<help@profitmandi.com>"
|
| 203 |
#print mTo
|
205 |
#print mTo
|
| 204 |
#mTo = ["manish.sharma@shop2020.in", "sandeep.sachdeva@shop2020.in", "chaitnaya.vats@shop2020.in", "manoj.kumar@shop2020.in", "chandan.kumar@shop2020.in", "khushal.bhatia@shop2020.in", "yukti.jain@shop2020.in", "ankush.dhingra@shop2020.in", "rajneesh.arora@shop2020.in", "kshitij.sood@shop2020.in", "anikendra.das@shop2020.in"]
|
206 |
mTo = ["manish.sharma@shop2020.in"]
|
| 205 |
|
207 |
|
| 206 |
for receipient in mTo:
|
208 |
for receipient in mTo:
|
| 207 |
m = Email('localhost')
|
209 |
m = Email('localhost')
|
| 208 |
m.setFrom(mFrom)
|
210 |
m.setFrom(mFrom)
|
| 209 |
print receipient[0]
|
211 |
print receipient[0]
|
| 210 |
m.addRecipient(receipient[0])
|
212 |
#m.addRecipient(receipient[0])
|
| - |
|
213 |
m.addRecipient('manish.sharma@shop2020.in')
|
| - |
|
214 |
|
| 211 |
#print receipient
|
215 |
#print receipient
|
| 212 |
message="""
|
216 |
message="""
|
| 213 |
<html>
|
217 |
<html>
|
| 214 |
<body>
|
218 |
<body>
|
| 215 |
<pre>
|
219 |
<pre>
|
| Line 232... |
Line 236... |
| 232 |
|
236 |
|
| 233 |
m.setSubject("ProfitMandi")
|
237 |
m.setSubject("ProfitMandi")
|
| 234 |
m.setTextBody(None)
|
238 |
m.setTextBody(None)
|
| 235 |
m.setHtmlBody(message)
|
239 |
m.setHtmlBody(message)
|
| 236 |
m.send()
|
240 |
m.send()
|
| - |
|
241 |
break
|
| 237 |
|
242 |
|
| 238 |
if session.is_active:
|
243 |
if session.is_active:
|
| 239 |
print "session is active. closing it."
|
244 |
print "session is active. closing it."
|
| 240 |
session.close()
|
245 |
session.close()
|