Subversion Repositories SmartDukaan

Rev

Rev 900 | Rev 1248 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 900 Rev 928
Line 27... Line 27...
27
def sendMail(mail):
27
def sendMail(mail):
28
    if not mail:
28
    if not mail:
29
        raise HelperServiceException(101, "mail not present")
29
        raise HelperServiceException(101, "mail not present")
30
    #msg = MIMEMultipart()
30
    #msg = MIMEMultipart()
31
    #mail = Mail()
31
    #mail = Mail()
-
 
32
    if mail.sender:
-
 
33
        mail.data = "This mail is sent by " + mail.sender + "\n" + mail.data
-
 
34
        
32
    msg = MIMEText(mail.data)
35
    msg = MIMEText(mail.data)
33
    msg['To'] = ', '.join( mail.to )
36
    msg['To'] = ', '.join( mail.to )
-
 
37
    if mail.sender:
-
 
38
        msg['From'] = mail.sender
-
 
39
    else:    
34
    msg['From'] = "help@saholic.com"
40
        msg['From'] = "help@saholic.com"
35
    msg['Subject'] = mail.subject
41
    msg['Subject'] = mail.subject
36
    #msg.attach(mail.data)
42
    #msg.attach(mail.data)
37
    
43
    
38
    #handle attachments in mail
44
    #handle attachments in mail
39
    if mail.attachments:
45
    if mail.attachments:
Line 45... Line 51...
45
            part.add_header('Content-Disposition',
51
            part.add_header('Content-Disposition',
46
                    'attachment; filename="%s"' % os.path.basename(attach))
52
                    'attachment; filename="%s"' % os.path.basename(attach))
47
            msg.attach(part)
53
            msg.attach(part)
48
    
54
    
49
    for to in mail.to:
55
    for to in mail.to:
50
        msg['To'] = to
-
 
51
        mail.sender = "help@shop2020.in"
56
        mail.sender = "help@shop2020.in"
52
        mail.password = "5h0p2o2o"
57
        mail.password = "5h0p2o2o"
53
        mailServer = smtplib.SMTP("smtp.gmail.com", 587)
58
        mailServer = smtplib.SMTP("smtp.gmail.com", 587)
54
        mailServer.ehlo()
59
        mailServer.ehlo()
55
        mailServer.starttls()
60
        mailServer.starttls()