예제 #1
0
파일: toolbox.py 프로젝트: MarlonMa/life
def send_mail(subject,
              content,
              smtp_server='smtp.yeah.net',
              port=25,
              sender='*****@*****.**',
              password=None,
              receiver=['*****@*****.**'],
              cc_receiver=[]):
    from email.mime.multipart import MIMEMultipart
    from email.mime.text import MIMEText
    from smtplib import SMTP as smtp
    from smtplib import SMTPServerDisconnected
    all_receivers = receiver + cc_receiver
    container = MIMEMultipart('alternative')
    container['Subject'] = subject
    container['From'] = sender
    container['To'] = ', '.join(receiver)
    container['CC'] = ', '.join(cc_receiver)
    content_plain = MIMEText(content, 'html')
    container.attach(content_plain)
    smtp_conn = smtp(smtp_server, port)
    smtp_conn.ehlo()
    smtp_conn.starttls()
    smtp_conn.login(sender, password)
    smtp_conn.sendmail(sender, all_receivers, container.as_string())
    smtp_conn.quit()
예제 #2
0
파일: faip.py 프로젝트: infoVip/SH
def sendip(oip):
    try:
        content = urllib2.urlopen("http://ddns.oray.com/checkip").read()
        ip = re.search('\d+\.\d+\.\d+\.\d+', content).group(0)
    except:
        ip = False

    if ip == oip:
        pass
    elif ip:
        oip = ip
        os.system(
            'curl http://username:[email protected]/ph/update?hostname=vvaa00.xicp.net&myip=%s'
            % ip)
        os.system(
            "curl -X POST https://dnsapi.cn/Record.Modify -d 'login_email=****@163.com&login_password=******&format=json&domain_id=16806793&record_id=68470074&sub_domain=www&value=%s&record_type=A&record_line=默认'"
            % ip)
        orighdrs = ['From:*******@163.com', 'To:******@163.com', 'Subject:IP']
        origbody = [ip]
        origmsg = '\r\n\r\n'.join(
            ['\r\n'.join(orighdrs), '\r\n'.join(origbody)])
        try:
            s = smtp('smtp.163.com')
            s.login('***@163.com', '******')
            errs = s.sendmail('****@163.com', ('****@163.com'), origmsg)
            s.quit()
        except:
            pass
    return ip
예제 #3
0
def send_mail(config, subject, message, files_to_attach):
    # unpack some config stuff
    email = config["email_config"]["email"]
    password = config["email_config"]["password"]
    email_name = config["email_config"]["name"]
    to_list = config["mailing_list"]["emails"]
    to_list_name = config["mailing_list"]["name"]

    # connect to gmail
    server = smtp('smtp.gmail.com', 587)
    server.ehlo()
    server.starttls()
    server.login(email, password)

    # build up the message
    msg = multipart.MIMEMultipart()
    msg.attach(text.MIMEText(message))
    msg['From'] = email_name
    msg['To'] = to_list_name
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject

    for f in files_to_attach:
        part = base.MIMEBase('application', "octet-stream")
        with open(f, "rb") as fp:
            part.set_payload(fp.read())
        encoders.encode_base64(part)
        part.add_header('Content-Disposition', 'attachment; filename="{0}"'.format(os.path.basename(f)))
        msg.attach(part)

    server.sendmail(email, to_list, msg.as_string())
    server.quit()
예제 #4
0
파일: app.py 프로젝트: Rouji/webscan
def email():
    addr = request.values.get('email', None)
    if not addr:
        return jsonify({'success': False, 'error': 'No email address specified.'}), 400
    if not scanned_images:
        return jsonify({'success': False, 'error': 'There are no scanned images to send.'}), 400

    msg = MIMEMultipart()
    msg['From'] = config.MAIL_FROM
    msg['To'] = addr
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = config.MAIL_SUBJECT
    msg.attach(MIMEText(config.MAIL_BODY))

    for i, img in enumerate(scanned_images.values()):
        filename = 'scan_'+str(i+1).rjust(3,'0')+'.jpeg'
        part = MIMEApplication(img[0], Name=filename)
        part['Content-Disposition'] = 'attachment; filename="{}"'.format(filename)
        msg.attach(part)

    conn = smtp(config.SMTP_SERVER)
    conn.set_debuglevel(False)
    conn.login(config.SMTP_USER, config.SMTP_PASSWORD)
    try:
        conn.sendmail(config.MAIL_FROM, addr, msg.as_string())
    except Exception as ex:
        return jsonify({'success': False, 'error': 'Failed sending email.'}), 500
    conn.quit()
    return jsonify({'success': True})
예제 #5
0
파일: mailsender.py 프로젝트: lehoon/python
	def __init__(self, host, port, username, password):
		self.__host         = host
		self.__port         = port
		self.__username     = username
		self.__password     = password
		self.__smtp         = smtp(self.__host, self.__port)
		self.__content_type = """Content-Type: text/html; charset=\"utf-8\""""
예제 #6
0
def send_welcome(email):
    FROM = 'customer_services@my_domain.com'
    TO = email
    BODY_success = "\r\nThankyou for joining the Food Coop! To make an order go to www.my_website.com\r\n\
Pick the items you want and copy-paste the code to customer_services@my_domain.com with the \
subject line of the email set to 'food' (all lower-case letters and without the quotation marks)\r\n\r\n\
If your order is successful you'll receive a confirmation email from the Food Coop within 5 minutes \
of you sending in your order\r\n\r\n\
Pickup is on Wednesday on Mars (on the first floor of the Food Department. We will put signs up \
on the day) from 12 to 3pm. See you there!\r\n\r\nThe Food Coop Team\r\n(automated email. \
write to customer_services@my_domain.com if you're having trouble)\r\n"
    SUBJECT_success = "Food Coop membership"
    message = 'From: ' + FROM + '\r\nTo: ' + TO + '\r\nSubject: ' + SUBJECT_success + '\r\n\r\n' + BODY_success
    SMTPSERVER = 'localhost'

    sendserver = smtp(SMTPSERVER)
    errors = sendserver.sendmail(FROM, TO, message)
    sendserver.quit()

    if len(errors) != 0:
        lp = open('welcome_errors', 'a')
        for eachline in errors:
            lp.write(eachline+'\n')
        lp.write('\n\n')
        lp.close()
def main(argv):
    try:
        opts, args = getopt.getopt(argv, "hu:p:",["user="******"pass="******"-u", "--user"):
            username = arg
        elif opt in ("-p", "--pass"):
            password = arg

    driver = get_driver()
    url = "https://gmp.oracle.com/captcha/"
    driver.get(url)

    sign_in(driver, username, password)

    america_btn = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "ext-gen18"))
    )
    america_btn.click()

    password_text = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "ext-gen38"))
    )

    text = password_text.text
    driver.quit()

    for line in text.split("\n"):
        if "Password" in line:
            mima = line.split(" ")[1]

    print mima

    receivers = ["Sha Bi No.1 <*****@*****.**>", "Sha Bi No.2 <*****@*****.**>", "Chao Shuai <*****@*****.**>"]
    # receivers = ["Mengwei Liu <*****@*****.**>"]
    sender = 'Larry Liu <*****@*****.**>'
    try:
        conn = smtp('stbeehive.oracle.com')
        conn.login(username, password)
        msg = MIMEText(mima)
        msg['Subject'] = "clear-guest mima"
        msg['From'] = sender
        msg['To'] = ",".join(receivers)
        conn.sendmail(sender, receivers, msg.as_string())
        print "Successfully sent email"
    except SMTPException as e:
        print e.message
        print "Error: unable to send email"
    finally:
        conn.close()
예제 #8
0
def sendmail():
    '使用SMTP协议发送邮件'
    serdServer = smtp()
    serdServer.connect(SMTPServer, '587')
    serdServer.starttls()  # 解决SMTP加密问题
    # serdServer.set_debuglevel(1) # 设置日志提示级别
    serdServer.login(from_addr, password)
    errs = serdServer.sendmail(from_addr, to_addr, origMsg)
    print('Mail Send Sucess!')
    serdServer.quit()
예제 #9
0
def scan_smtp(server_name, uname, upass):
    host = 'smtp.' + server_name + '.com'
    port = 25
    try:
        s = smtp(host, port)
        s.login(uname, upass)
        print "[+]sucess: %s: %s" % (uname, upass)
        return True
    except Exception:
        print "[-]failed: %s %s" % (uname, upass)
    return False
예제 #10
0
 def __init__(self, server, username = None, password = None, debug = False):
     self.smtp = smtp(server)
     self.smtp.set_debuglevel((1 if debug == True else 0))
     try:
         if username == None:
             self.smtp.login('*****@*****.**', 'm1i2n3g4')
         else:
             self.smtp.login(username, password)
     except Exception:
         self.init = False
     else:
         self.init = True
def sendFailureEmailAlert(errMsg):
    msg = EmailMessage()
    msg.set_content(errMsg)
    msg['Subject'] = 'Failed to Update CloudFlare DDNS'
    msg['From'] = '*****@*****.**'  # Change this
    msg['To'] = '*****@*****.**'  # Change this

    server = smtp('mail.xxxx.com', 587)  # Change this
    server.starttls()
    server.login('*****@*****.**', 'mypassword')  # Change this
    server.send_message(msg)
    server.quit()
예제 #12
0
파일: gmail.py 프로젝트: wwq0327/lovepy
    def send(self, to, title, content):
        server = smtp('smtp.gmail.com')
        server.docmd("EHLO server")
        server.starttls()
        server.login(self.account, self.password)

        msg = MIMEText(content)
        msg['Content-Type'] = "text/plain; charset='utf-8'"
        msg['Subject'] = title
        msg['From'] = self.account
        msg['To'] = to
        server.sendmail(self.account, to, msg.as_string())
        server.close()
예제 #13
0
    def run(self):
        try:
            msg = MIMEText(self.MAILBODY, _subtype='html', _charset='utf8')
            msg['Subject'] = Header(self.SUBJECT, 'utf8')
            msg['From'] = self.SENDER
            msg['To'] = self.RECEIVER
            s = smtp(self.SMTP_HOST)
            s.set_debuglevel(0)
            s.login(self.SMTP_USER, self.SMTP_PASSWD)
            s.sendmail(self.SENDER, self.RECEIVER, msg.as_string())

        except:
            print traceback.print_exc()
            return False
def confirm_order(email, status, order_list = False): #status is failed (for bad formatting) or success or request or not_listed
    FROM = '*****@*****.**'
    TO = email
    BODY_success = "\r\nOrder completed! See you on Wednesday between 12 and 3pm\r\n\r\nThe Food Coop Team\r\n(automated email. \
write to [email protected] if you're having trouble)\r\n"
    SUBJECT_success = "Food Coop: order completed"
    BODY_failed = "\r\nwe couldn't complete your order! computer sais: 'you entered order in the wrong format'\
\r\nIf you think its wrong please email me at [email protected]\r\n"
    SUBJECT_failed = "Food Coop couldn't complete your order this time"
    BODY_failed_helper = "\r\nthe following couldnt process their food coop order: " + email + "\r\n"
    SUBJECT_failed_helper = "\r\n food coop order failed for " + email
    BODY_request = order_list
    SUBJECT_request = "food coop order list"
    BODY_not_listed = "\r\nFood Coop couldn't complete your order because you are not on our Food Coop members list!\r\n\
To get on the list just speak to one of the Food Coop team by emailing [email protected]\r\n"
    SUBJECT_not_listed = "Food Coop - you need to register first"

    if status == 'success':
        message = 'From: ' + FROM + '\r\nTo: ' + TO + '\r\nSubject: ' + SUBJECT_success + '\r\n\r\n' + BODY_success
    elif status == 'failed':
        message = 'From: ' + FROM + '\r\nTo: ' + TO + '\r\nSubject: ' + SUBJECT_failed + '\r\n\r\n' + BODY_failed
        message_helper = 'From: ' + FROM + '\r\nTo: ' + TO + '\r\nSubject: ' \
+ SUBJECT_failed_helper + '\r\n\r\n' + BODY_failed_helper
    elif status == 'request':
        message = 'From: ' + FROM + '\r\nTo: ' + TO + '\r\nSubject: ' + SUBJECT_request + '\r\n\r\n' + BODY_request
    elif status == 'not_listed':
        message = 'From: ' + FROM + '\r\nTo: ' + TO + '\r\nSubject: ' + SUBJECT_not_listed + '\r\n\r\n' + BODY_not_listed

    SMTPSERVER = 'localhost'

    sendserver = smtp(SMTPSERVER)
    errors = sendserver.sendmail(FROM, TO, message)

    if status =='failed':
        errors_helper = sendserver.sendmail(FROM, '*****@*****.**', message_helper)
        if len(errors_helper) != 0:
            fp = open('errors', 'a')
            for eachline in errors:
                fp.write(eachline+'\n')
            fp.write('\n\n')
            fp.close()

    sendserver.quit()

    if len(errors) != 0:
        fp = open('errors', 'a')
        for eachline in errors:
            fp.write(eachline+'\n')
        fp.write('\n\n')
        fp.close()
예제 #15
0
    def send_email(self, msg_string, from_email, to_email):
        """Send email via SMTP. For internal use.

        :arg str msg_string: strigified reply email
        :arg str from_email: From: address
        :arg str to_email: To: address
        """
        if config.smtp_server == 'localhost':
            s = smtplib.smtp(config.smtp_server)
        else:
            s = smtplib.smtp_ssl(config.smtp_server)
            s.login(config.smtp_username, config.smtp_password)

        s.sendmail(from_email, [to_email], msg_string)
        s.quit()
예제 #16
0
def main():
  ret = True
  try:
    msg = MIMEText('hello,this is text','plain','utf-8')
    msg['From'] = _format_addr('python爱好者<%s>' % from_addr)
    msg['To'] = _format_addr('管理员<%s>' % to_addr)
    msg['Subject'] = Header('这是测试邮件。。。','utf-8').encode()
    
    server = smtp(smtp_server)
    server.set_debuglevel(1)
    #server.login(from_addr,password)
    server.sendmail(from_addr,[to_addr],msg.as_string())
    server.quit()
  except Exception:
    ret = False
  retrun ret
예제 #17
0
def sendmail_thread(msg):
    try:
        username = conf.emailusername 
        password = conf.emailpassword
        
        mail = mimetext(msg)
        mail['Subject'] = conf.emailsubject
        mail['From'] = conf.emailfromaddress
        mail['To'] = conf.emailtoaddress

        mailserver = smtp(conf.emailserver)
        mailserver.starttls() 
        mailserver.login(conf.emailusername, conf.emailpassword)  
        mailserver.sendmail(mail['From'], mail['To'], mail.as_string())      
        mailserver.quit()  
    except:
        logger.info('error trying to send email')
예제 #18
0
    def __init__(self, conf):
        self.from_addr = conf.sender
        self.smtp = smtp(conf.mail_server)
	self.debug = False
        self.password = conf.sender_password
        self.report_file = conf.report_name+'.html'
        self.address_list = conf.address_list
        self.smtp.set_debuglevel((1 if self.debug == True else 0))
        try:
            if self.username == None:
                self.smtp.login('*****@*****.**', '1q2w3e4r')
            else:
                self.smtp.login(self.from_addr,self.password)
        except Exception:
            self.init = False
        else:
            self.init = True
예제 #19
0
def sendmail_thread(msg):
    try:
        username = conf.emailusername
        password = conf.emailpassword

        mail = mimetext(msg)
        mail['Subject'] = conf.emailsubject
        mail['From'] = conf.emailfromaddress
        mail['To'] = conf.emailtoaddress

        mailserver = smtp(conf.emailserver)
        mailserver.starttls()
        mailserver.login(conf.emailusername, conf.emailpassword)
        mailserver.sendmail(mail['From'], mail['To'], mail.as_string())
        mailserver.quit()
    except:
        logger.info('error trying to send email')
예제 #20
0
 def send_cipher():
     cipher = AES.new(key.get().encode('utf-8'), AES.MODE_EAX)
     ciphertext, tag = cipher.encrypt_and_digest(
         self.text.get('1.0', 'end').encode('utf-8'))
     result = [
         b64encode(x).decode('utf-8')
         for x in (cipher.nonce, ciphertext, tag)
     ]
     self.message += "From: <{login}>\nTo: <{receiver}>\nSubject: {subject}\n{text}".format(
         login=self.login,
         receiver=self.receiver.get(),
         subject=self.subject.get(),
         text=' '.join(result))
     mail = smtp('smtp.gmail.com', 465)
     mail.login(self.login, self.password)
     mail.sendmail(self.login, [self.receiver.get()],
                   self.message)
     print("Successfully sent email")
예제 #21
0
    def send_mail(self, date, identifier, ctype, location, ip, cs,
                  ua=None, user=None, loc=None, filename=None):
        """Send email message."""

        try:

            s = smtp(self.settings.smtp_server, self.settings.smtp_port)
            s.ehlo()

            msg = self._construct_msg(date, identifier, ctype, location,
                                      ip, ua, user, loc, cs, filename)

            recv = recv if 'recv' in locals() else self.settings.default_recv
            s.sendmail(f"{self.settings.sender}", recv,
                       msg.as_string())

        except Exception as e:
            CanaryLogItem.log_message_id(None, identifier, e)
예제 #22
0
def alarm_email(SERVER,USER,PASSWORT,FROM,TO,SUBJECT,MESSAGE):
    logger.info('Send mail!')
    from smtplib import SMTP as smtp
    from email.mime.text import MIMEText as text

    s = smtp(SERVER)

    s.login(USER,PASSWORT)

    m = text(MESSAGE)

    m['Subject'] = SUBJECT
    m['From'] = FROM
    m['To'] = TO


    s.sendmail(FROM,TO, m.as_string())
    s.quit()
예제 #23
0
def send_mail():
    server = smtplib.smtp('smtp.gmail.com', 587)
    server.ehlo()
    server.starttls()
    server.ehlo()

    server.login('your email address', 'your password')

    subject = "Suprise, Price fell down!"
    body = "Check out the link https://www.amazon.in/Boya-Microphone-Universal-Directional-Smartphone/dp/B076BCM26H/ref=sr_1_2?dchild=1&keywords=boya+mic&qid=1591025438&s=musical-instruments&sr=1-2"

    msg = f"Subject: {subject}\n\n{body}"

    server.send_mail()('enter from email address', 'enter to email address',
                       msg)

    print('Email has been sent')

    server.quit()
예제 #24
0
def confirm_order(email='*****@*****.**'):
    NAME = email
    FROM = '*****@*****.**'
    TO = NAME
    BODY = '\r\norder complete!\r\n'
    SMTPSERVER = 'localhost'

    message = 'From: ' + FROM + '\r\nTo: ' + TO + '\r\nSubject: Food order\r\n\r\n' + BODY

    sendserver = smtp(SMTPSERVER)
    errors = sendserver.sendmail(FROM, TO, message)
    sendserver.quit()

    if len(errors) != 0:
        fp = open('errors', 'a')
        for eachline in errors:
            fp.write(eachline+'\n')
        fp.write('\n\n')
        fp.close()
예제 #25
0
    def send_email(self, barcode_file, subject_job_name, email_address):

        filename = os.path.basename(barcode_file)

        # Create the email
        msg = MIMEMultipart()
        msg['From'] = self.email_config['user']
        msg['To'] = email_address
        msg['Subject'] = f'Your barcodes'

        # Attach the message body
        message = f'Your barcodes for {subject_job_name} are attached'
        msg.attach(MIMEText(message, 'plain'))

        # Attach the output file
        try:

            with open(barcode_file) as attachment:
                message_attachment = MIMEBase('multipart', 'plain')
                message_attachment.set_payload(attachment.read())
                encoders.encode_base64(message_attachment)
                message_attachment.add_header("Content-Disposition", "attachment", filename=filename)
                msg.attach(message_attachment)

        except OSError as e:
            print(f'There was an error reading the barcode output file ({barcode_file}) while attaching it to the email'
                  f' for {email_address}')
            raise e

        # If the attachment was successful, send the email
        else:

            smtp_server = smtp(self.email_config['smtp_server'], self.email_config['smtp_port'])
            smtp_server.starttls()
            # Login Credentials for sending the mail
            smtp_server.login(self.email_config['user'], self.email_config['password'])
            print(f'Sending email to: {email_address}')
            smtp_server.sendmail(msg['From'], msg['To'], msg.as_string())
            smtp_server.quit()
예제 #26
0
파일: faip.py 프로젝트: ChainBoy/SH
def sendip(oip):    
    try:
        content = urllib2.urlopen("http://ddns.oray.com/checkip").read()
        ip = re.search('\d+\.\d+\.\d+\.\d+',content).group(0)
    except:
        ip = False

    if ip == oip:
        pass
    elif ip:
        oip = ip
        os.system('curl http://username:[email protected]/ph/update?hostname=vvaa00.xicp.net&myip=%s' %ip)
        os.system("curl -X POST https://dnsapi.cn/Record.Modify -d 'login_email=****@163.com&login_password=******&format=json&domain_id=16806793&record_id=68470074&sub_domain=www&value=%s&record_type=A&record_line=默认'" %ip)
        orighdrs = ['From:*******@163.com', 'To:******@163.com','Subject:IP' ]
        origbody = [ip]
        origmsg = '\r\n\r\n'.join(['\r\n'.join(orighdrs),'\r\n'.join(origbody)]) 
        try:
            s = smtp('smtp.163.com')
            s.login('***@163.com','******')
            errs = s.sendmail('****@163.com',('****@163.com'),origmsg)
            s.quit()
        except:
            pass
    return ip
예제 #27
0
 def __init__(self):
     self.server = smtp(config.MAIL_SERVER_NAME + ":" +
                        str(config.MAIL_SERVER_PORT))
     if config.MAIL_SERVER_USE_TLS:
         self.server.starttls()
     self.server.login(config.FROM_ID, config.FROM_PASSWORD)
예제 #28
0
#!/usr/bin/env python3
#-*- coding:utf-8 -*-
'''
邮件发送
'''
from smtplib import SMTP_SSL as smtp
sm = smtp('smtp.qq.com', 465)
print(sm)
sm.login('*****@*****.**', 'ruhwxunbmyskbbdf')

#ret=sm.sendmail('*****@*****.**','*****@*****.**','''From:qinhan\r\nTo:qinhan\r\nSubject:hello world\r\n\r\nthis is a test mail''')
#print(ret)

sm.quit()

from imaplib import IMAP4_SSL as imaps
imap = 'imap.qq.com'
im = imaps(imap)
im.login('*****@*****.**', 'ruhwxunbmyskbbdf')
ret = im.select('INBOX', False)
print(ret)
ret = im.fetch('68', '(BODY[TEXT])')
print(ret)
예제 #29
0
파일: smtp.py 프로젝트: hxssgaa/LearnPython
from smtplib import SMTP as smtp

s = smtp('smtp.126.com')
s.login('hxdavidtest001', '68671388aa')
s.set_debuglevel(1)
s.sendmail(
    '*****@*****.**',
    ('*****@*****.**', '*****@*****.**'), ''' \
From: [email protected]\r\nTo:[email protected], [email protected]\r\nSubject: test email\r\n\r\nxxx \
asdasdasda\r\n.''')
예제 #30
0
#!/usr/bin/env python3

from smtplib import SMTP as smtp
from email.mime.text import MIMEText

from_addr = input("From: ")
password = input("Password: "******"To: ")
#  smtp_server = input("SMTP server: ")
smtp_server = 'smtp.163.com'
message = MIMEText("Hello, i am an email...", 'plain', 'utf-8')

server = smtp(smtp_server)
server.set_debuglevel(1)
server.login(from_addr, password)
server.sendmail(from_addr, [to_addr], message.as_string())
server.quit()
예제 #31
0
import smtplib

msg = "TESTINGINGGININGIN"
me = '*****@*****.**'
you = '*****@*****.**'
s = smtplib.smtp('localhost')
s.sendmail(me, you, msg)
s.quit()
예제 #32
0
from smtplib import SMTP as smtp

mail_host = 'smtp.qq.com'
mail_user = '******'
mail_pass = '******'

to_list = ('*****@*****.**')
#msg['Subject'] = smtplib test
#msg['From'] = mail_user
#msg['To'] = ';'.join(to_list)
msg='''From: [email protected]\r\nTo: [email protected]\r\nSubject: smtplib test msg\r\n\r\nXXXXXX\r\n.'''

s = smtp()
s.connect(mail_host)
s.login(mail_user,mail_pass)
s.sendmail(mail_user,to_list,msg)
s.quit()
def sendmail(sender_add, reciever_add, msg, password):
    server = smtp('smtp.gmail.com:587')
    server.starttls()
    server.login(sender_add, password)
    server.sendmail(sender_add, reciever_add, msg)
    print("Mail sent succesfully....!")
예제 #34
0
        # wait an hour
        time.sleep(3600)
        #continue with the script
        continue

# else if the phrase "Flash Voyager" apears at all
else:
    # create and email
    msg = 'Stock Check: Flash Voyager is in stock'
    # set the from address
    fromaddr = '*****@*****.**'
    # set the to address
    toaddrs = '*****@*****.**'

    # setup the email server
    server = smtplib.smtp('smtp.gmail.com', 587)
    server.starttls()
    # add an account
    server.Login("*****@*****.**", "Password")

    # print the emails contents
    print('From: ' + fromaddr)
    print('To: ' + toaddrs)
    print('Message: ' + msg)

    # Send the emails
    server.sendmail(fromaddr, toaddrs, msg)
    # disconnect from the server
    server.quit()

    break
예제 #35
0
import smtplib
conn = smtplib.smtp('emailserver', port)
conn.ehlo()
conn.starttls()
conn.login('email', 'password')
conn.sendmail('sendingemail', 'sendingemail', 'Subject: Subject \n\n Body.')
예제 #36
0
                    if not os.path.isdir(dstDir):
                        print "Creating directory "+dstDir
                        os.mkdir(dstDir)
                    dstFile = dstDir + fileName
                    with open(dstFile, 'wb') as f:
                        for chunk in r.iter_content(chunk_size=1024): 
                            if chunk: 
                                f.write(chunk)
                
                    cur.execute("INSERT INTO backup(idActivity,Name,Date,Type,File) VALUES (?,?,?,?,?)",(currentActivityId,currentActivityName,activity['beginTimestamp'],tmpUrl[0],dstFile))
                    con.commit()
                    formatDownloaded += 1

        if formatDownloaded > 1 :
            message += "\r\n"
    currentPage += 1
    if nbDownPage == 0:
        end = 1
con.close()


if mailEnable and nbDown > 0 :
    message = message.encode("UTF8")
    if useSmptSSL :
        smtpObj = smtplib.SMTP_SSL(smtpSrv)
    else :
        smtpObj = smtplib.smtp(smtpSrv)
    smtpObj.login(smtpUser,smtpPwd)
    smtpObj.sendmail(mailFrom, mailTo, message)         
    print "Successfully sent email"
    smtpObj.quit()