コード例 #1
0
def usermail(sender_mail, sender_name, msg):
    s = SMTP("smtp.gmail.com", 587)
    s.ehlo()
    s.starttls()
    s.ehlo()

    s.login('*****@*****.**', 'samsunghp')

    mu = text(
        "Hi " + sender_name + ",\n\n" +
        "Your message has been recieved by us and we will responded to it soon."
        +
        "\nThank-you for communicating with us, hope your query will cleared by our team."
        + "\n\n\nKOSS IIT Kharagpur")

    mu['Subject'] = "KOSS:query recieved will be responded soon"
    mu['From'] = '*****@*****.**'
    mu['To'] = "*****@*****.**"

    mk = text("Query from " + sender_name + ",\n\n" + msg +
              "\n\nRespond to the email-id below:\n" + sender_mail)

    mk['Subject'] = "Query"
    mk['From'] = '*****@*****.**'
    mk['To'] = "*****@*****.**"

    try:
        s.sendmail('*****@*****.**', "*****@*****.**",
                   mu.as_string())
        s.sendmail('*****@*****.**', "*****@*****.**",
                   mk.as_string())
    except:
        print("email failed")

    s.quit()
コード例 #2
0
    def sendEmail(self):
        port = 465

        self.rcptlist = self.getSubsList()
        receivers = ','.join(self.rcptlist)

        msg = MIMEMultipart('mixed')
        #msg['Subject'] = 'Surely He will save you from the fowlers snare and from these deadly memes. Test #' + self.counter
        msg['Subject'] = 'In the beginning was the Meme, and the Meme was with God: Day ' + self.counter
        msg['From'] = self.Email_address
        msg['To'] = receivers

        memeDescription = """
            <html>
                <head>
                    <style type="text/css" media="screen">
                        p.text{ 
                            font-size: 200%; 
                            font-family: 'Garamond';
                            text-align: center;
                        } 
                    </style>
                </head>
                <body>
                    <p class = 'text'>""" + self.Blessings22 + """</p>
                </body>
            </html>
            """

        msg.attach(text(memeDescription, 'html', 'utf-8'))
        msg.attach(
            text(
                '<html><body><p><img src = "' + self.Blessings23 +
                '"></p></body></html>', 'html', 'utf-8'))
        msg.attach(
            text(
                'This meme was found and emailed to you automatically, courtesy of the Python programming language\n Warning: Memes are not curated.\n\n',
                'plain', 'utf-8'))
        msg.attach(
            text('Why Did I Do This? To Measure The Limits of My Abilities',
                 'plain', 'utf-8'))

        context = ssl.create_default_context()

        with smtplib.SMTP_SSL("smtp.gmail.com", port,
                              context=context) as server:
            server.login(self.Email_address, self.Email_password)
            server.sendmail(self.Email_address, self.rcptlist, msg.as_string())
コード例 #3
0
ファイル: wlt_2_comp.py プロジェクト: Metric-nz/WLANThermo_v2
def alarm_email(SERVER,USER,PASSWORT,STARTTLS,FROM,TO,SUBJECT,MESSAGE):
    logger.info('Send mail!')
    
    from smtplib import SMTP 
    from smtplib import SMTPException 
    from email.mime.text import MIMEText as text
    if STARTTLS:
        port=587
    else:
        port=25
    try:
        s = SMTP(SERVER,port)
        if STARTTLS:
            s.starttls()
        
        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()
        logger.debug('Alarmmail gesendet!')
    except SMTPException as error:
        sendefehler = "Error: unable to send email :  {err}".format(err=error)
        logger.error(sendefehler)
    except:
        sendefehler = "Error: unable to resolve host (no internet connection?) :  {err}"
        logger.error(sendefehler)
コード例 #4
0
ファイル: send_email.py プロジェクト: wgb128/gearbest-prices
def send_email(server, port, subject, message):

    # Get ENV variables to send an email
    SMTP_USER = os.getenv('SMTP_USER')
    SMTP_PASS = os.getenv('SMTP_PASS')
    SMTP_FROM = os.getenv('SMTP_FROM')
    SMTP_TO = os.getenv('SMTP_TO')

    # check if ENV exist
    if not SMTP_USER or not SMTP_PASS or not SMTP_FROM or not SMTP_TO:
        log.error('No credetials provided.')
        return 0

    # create structure of email
    email = text(message)
    email['Subject'] = subject
    email['From'] = SMTP_FROM
    email['To'] = SMTP_TO

    # sending an email
    try:
        smtp = smtplib.SMTP('%s:%s' % (server, port))
        smtp.starttls()
        smtp.login(SMTP_USER, SMTP_PASS)
        smtp.sendmail(SMTP_FROM, SMTP_TO, email.as_string())
        smtp.quit()
        return 1

    except smtplib.SMTPException as e:
        log.error(e)
        return 0
コード例 #5
0
ファイル: SendGmail.py プロジェクト: sadams69/PyHouse
def Send(msg = 'Test' , to = PrivateHouseEmail['to']):  
    fromaddr = PrivateHouseEmail['from'] 
    toaddrs  = to  
  
    # Credentials (if needed)  
    username = PrivateHouseEmail['username']  
    password = PrivateHouseEmail['password']
    # I'm sure that this breaks every security rule ever made. But right now this is all I know how to do. 
    # PrivateHouse
   
    m = text(msg)
    m['Subject'] = 'HousePi Door Alert'
    m['From'] = fromaddr
    m['To'] = toaddrs


    # The actual mail send  
    server = smtplib.SMTP('smtp.gmail.com:587')  
    server.starttls()  
    server.login(username,password)
    print 'From: %s' % fromaddr
    print 'to: %s' % toaddrs
    print msg
    
    server.sendmail(fromaddr, toaddrs, m.as_string())  
    server.quit()
コード例 #6
0
def send_email(sentence):
  """
    Dispatch: send
    Function to send an email.
    Example: "Send an email."
  """
  import smtplib
  from email.mime.text import MIMEText as text
  import alan
  import language.questions
  try:
    # Send the mail.
    alan.speak("I'm preparing to send an email.")
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.starttls()
    # TODO add alan's email and password here
    email = language.questions.ask_for_email("What is the sender email?")
    alan.speak("What is your password")
    password = alan.listen()
    server.login(email, password)
    recipient = language.questions.ask_for_email("What is the recipient email?")
    message = language.questions.ask_for_text("What is the message?")
    mime_message = text(message)
    mime_message['Subject'] = language.questions.ask_for_text("What is the subject?")
    server.sendmail(email, recipient, mime_message.as_string())
    server.quit()
    return "Email sent."
  except:
    alan.speak("Something went wrong.")
    if "gmail" in email:
      return "Try allowing less secure apps in your gmail settings."
    else:
      return "I can't seem to send email right now."
コード例 #7
0
ファイル: utils.py プロジェクト: Elizabwth/elizabwth-web
def send_email(request):
	form = forms.ContactForm(request.form)
	data = request.form

	msg = "From: "+data['name']+" <"+data['email']+">\n"+ \
		  "Reason: "+data['reason']+"\n"+ \
		  "------------\n"+ \
		  "Message:\n"+ \
		  data['message']
	message = text(msg)
	message['Subject'] = data['subject']
	message['From'] = settings.MAIL_ADDRESS
	message['To'] = settings.MAIL_ADDRESS
	message['Reply-to'] = data['email']
	
	if form.validate():
		s = smtplib.SMTP(settings.MAIL_SERVER, 587)
		s.ehlo()
		s.starttls()
		s.ehlo
		
		try:
			s.login(settings.MAIL_ADDRESS, MAIL_PASSWD)
			s.sendmail(message['From'], [message['To']], message.as_string())
			s.quit()
			return 'success'
		except:
			s.quit()
			return 'server_error'
	else:
		return 'input_error'
コード例 #8
0
def sendmail():  #fucntion for sending mail
	# user_value = doctor_USERS_COLLECTION.find({'_id':session['username']})
	# uservalue = user_value[0]
	# doctoremail = doctor_email_id
	if request.method == 'POST':
		patientname = request.form['name']
		patientemail = request.form['email']
		requested_date = request.form['date']
		time = request.form['time']
		mobile = request.form['mobile']
		doctoremail = request.form['doctoremail']
		
		TEXT = "\n\n"

		TEXT = TEXT + """
						DOCTOR-EMAIL :%s
						PATIENT-NAME :%s
						PATIENT-EMAIL :%s
						PATIENT-MOBILE :%s
						REQUESTED-DATE: %s
						APPOINTMET-TIME: %s
						""" % (str(doctoremail),str(patientname),str(patientemail),str(mobile),str(requested_date),str(time))
		
		#Prepare actual message
		m = text(TEXT)
		m['Subject'] = "REQUEST FOR APPOINTMENT"
		m['From'] = "*****@*****.**"
		m['To'] = doctoremail + "," + patientemail
		server = smtplib.SMTP(host='smtp.gmail.com', port=587)
		server.starttls()
		server.login("*****@*****.**","diabocare123")
		server.sendmail(m['From'], m['To'], m.as_string())
		server.quit()
		return redirect(url_for('home'))
コード例 #9
0
        def send_email(self, subject, message):
                gmail_user = '******'
                gmail_password = '******'

                sent_from = gmail_user

                subject = self.hostname + ': ' + subject

                m = text(message)

                m['Subject'] = subject
                m['From'] = 'Deployment Alert<' + sent_from + '>'
                m['To'] = ", ".join(self.alert_email)

                try:
                        server = smtplib.SMTP('smtp.gmail.com', 587)
                        server.starttls()
                        server.login(gmail_user, gmail_password)
                        server.sendmail(sent_from, self.alert_email, m.as_string())
                        server.close()

                except Exception as e:
                        msg = "!!!!!!!!!! EXCEPTION !!!!!!!!!"
                        msg = msg + str(e)
                        msg = msg + traceback.format_exc()
                        logger.error(msg)
コード例 #10
0
    def send_email(self, subject, msg):
        FROM = self.email_id
        TO = ['<email_id>']
        CC = ['<email_id>', '<email_id>']
        SUBJECT = subject
        TEXT = msg

        # Prepare actual message
        message = text(msg)
        message['Subject'] = 'Hello!'
        message['From'] = FROM
        message['To'] = ','.join(TO)
        import pdb
        pdb.set_trace()
        try:
            print("Sending Email... ")
            context = ssl.create_default_context()
            server = smtplib.SMTP('smtp.office365.com', 587)
            # server.ehlo()
            # server.starttls()
            server.login(self.email_id, self.email_password)
            server.sendmail(FROM, TO, message.as_string())
            server.close()
            print('Email Sent Successfully')
        except Exception as e:
            print(e)
            print("Failed to send email")
コード例 #11
0
ファイル: job.py プロジェクト: siqueries/datioml
    def send_email(names, from_address, to_address, subject, body):
        #print "about to send email to %s" % to_address
        m = MIMEMultipart("alternative")
        #m.attach(text(body, "plain"))
        m.attach(text(body, "html"))
        m['Subject'] = subject
        m['From'] = str(EmailAddress(from_address, "SiQueries"))
        m['To'] = str(EmailAddress(to_address, names))

        logger.info(m)

        smtp_server = 'smtp.mandrillapp.com'
        smtp_username = '******'
        smtp_password = '******'
        smtp_port = '587'
        smtp_do_tls = True

        server = smtplib.SMTP(
            host=smtp_server,
            port=smtp_port,
            timeout=10
        )
        #server.set_debuglevel(1)
        server.starttls()
        server.ehlo()
        server.login(smtp_username, smtp_password)
        server.sendmail(from_address, to_address, m.as_string())
        server.quit()
        logger.info("email should have gone")
コード例 #12
0
def sendEmail():
    try:

        receipient = input(" Insert the reciepient's email address >>").lower()

        print(" ")
        sender = input(" Insert the sender's email address >>").lower()
        print(" ")
        subject = input("What is the Email SUbject? >>")
        print(" ")
        message = input(" Compose your message here >>").capitalize()
        print(" ")

        m = text(message)
        m['Subject'] = subject
        m['From'] = sender
        m['To'] = receipient

        server = smtplib.SMTP('smtp.gmail.com', 587)
        server.starttls()
        server.login("*****@*****.**", "xxxxxx")

        server.sendmail(sender, receipient, m.as_string())
        server.quit()

        print("Email Successfully Sent")
    except:
        print("Email Not Sent")
コード例 #13
0
def alarm_email(SERVER,USER,PASSWORT,STARTTLS,FROM,TO,SUBJECT,MESSAGE):
    logger.info(_(u'Send mail!'))
    
    from smtplib import SMTP 
    from smtplib import SMTPException 
    from email.mime.text import MIMEText as text
    if STARTTLS:
        port=587
    else:
        port=25
    try:
        s = SMTP(SERVER,port)
        if STARTTLS:
            s.starttls()
        
        s.login(USER,PASSWORT)
        

        m = text(MESSAGE, 'plain', 'UTF-8')

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


        s.sendmail(FROM,TO, m.as_string())
        s.quit()
        logger.debug(_(u'Alert Email has been sent!'))
    except SMTPException as error:
        sendefehler = _(u'Error: unable to send email: {err}').format(err=error)
        logger.error(sendefehler)
    except:
        #TODO err undefined!
        sendefehler = _(u'Error: unable to resolve host (no internet connection?) :  {err}')
        logger.error(sendefehler)
コード例 #14
0
ファイル: mailer.py プロジェクト: KeerthanaP/Code-snippet
 def make_mail(self):
     subject, mail_body = (
         "You've received a mail",
         "Hi, you have successfully triggered the mail! Congrats :D")
     msg = text(mail_body)
     msg['Subject'] = subject
     return msg
コード例 #15
0
    def EmailSender(self):
        try:    
            message=self.msg.toPlainText()
            sndr=self.sender.text()
            receipient=self.receiver.text()
            subject=self.subjectText.text()

            m=text(message)
            m['Subject']=subject
            m['From']=sndr
            m['To']=receipient
                
            
            server= smtplib.SMTP('smtp.gmail.com',587)
            server.starttls()
            server.login("*****@*****.**","xxxxxx")
            server.sendmail(sndr,receipient, m.as_string())
            server.quit()
            self.msg.clear()
            self.sender.clear()
            self.receiver.clear()

            QMessageBox.information (self,"Email Alert","Email Successfully Sent")
           
        except:
            QMessageBox.information (self,"Email Alert","Check your inputted information")
コード例 #16
0
    def send_email(self, subject, msg):
        FROM = self.email_id
        TO = ['<email_id>']
        CC = ['<email_id>', '<email_id>']
        SUBJECT = subject
        TEXT = msg

        # Prepare actual message
        m = text(msg)
        m['Subject'] = 'Sample Email'
        m['From'] = FROM
        m['To'] = ','.join(TO)

        try:
            print("Sending Email... ")
            context = ssl.create_default_context()
            server = smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context)
            # server.ehlo()
            # server.starttls()
            server.login(self.email_id, self.email_password)
            server.sendmail(FROM, TO, m.as_string())
            server.close()
            print('Email Sent Successfully')
        except Exception as e:
            print(e)
            print("Failed to send email")
コード例 #17
0
def send_email(args):
 
        m = text(args[4])
        m['Subject'] = args[3]
        m['From'] = args[1]
        m['To'] = args[2]
        #print "Message length is " + repr(len(msg))

        #Change according to your settings
        smtp_server = 'email-smtp.us-east-1.amazonaws.com'
        smtp_username = '******'
        smtp_password = '******'
        smtp_port = '587'
        smtp_do_tls = True

        server = smtplib.SMTP(
            host = smtp_server,
            port = smtp_port,
            timeout = 10
        )
        server.set_debuglevel(10)
        server.starttls()
        server.ehlo()
        server.login(smtp_username, smtp_password)
        server.sendmail(args[1], args[2], m.as_string())

        print "email should have gone"
コード例 #18
0
ファイル: wlt_2_comp.py プロジェクト: MarioWi/WLANThermo_v2
def alarm_email(SERVER, USER, PASSWORT, STARTTLS, FROM, TO, SUBJECT, MESSAGE):
    logger.info('Send mail!')

    from smtplib import SMTP
    from smtplib import SMTPException
    from email.mime.text import MIMEText as text
    if STARTTLS:
        port = 587
    else:
        port = 25
    try:
        s = SMTP(SERVER, port)
        if STARTTLS:
            s.starttls()

        s.login(USER, PASSWORT)

        m = text(MESSAGE, 'plain', 'UTF-8')

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

        s.sendmail(FROM, TO, m.as_string())
        s.quit()
        logger.debug('Alarmmail gesendet!')
    except SMTPException as error:
        sendefehler = "Error: unable to send email :  {err}".format(err=error)
        logger.error(sendefehler)
    except:
        sendefehler = "Error: unable to resolve host (no internet connection?) :  {err}"
        logger.error(sendefehler)
コード例 #19
0
ファイル: sample.py プロジェクト: Hirabayashi623/Python
def create_message(from_addr, to_addr, subject, body):
    msg = text(body)
    msg['Subject'] = subject
    msg['From'] = from_addr
    msg['To'] = to_addr
    msg['Date'] = fmt()
    return msg
コード例 #20
0
def send_mail(full_details):  #fucntion for sending mail
    if (isinstance(full_details, list)):
        TEXT = "\n\n"
        for i in range(len(full_details)):
            TEXT = TEXT + """
						REQUESTED-URL: %s
						USER-IP: %s
						ACTIVE-RECORD-TIME: %s
						TIME-STAMP: %s
						ACTION-CONTROL: %s

						
						""" % ((full_details[i])['requested_url'], (full_details[i])['ip'],
             (full_details[i])['active_record_time'],
             (full_details[i])['time_stamp'],
             (full_details[i])['action_control'])
    else:
        TEXT = """
						ERROR: %s
						""" % (full_details)
    # Prepare actual message
    m = text(TEXT)

    m['Subject'] = (LOG_keywords.MAIL_SUBJECT.value)[loop_count]
    m['From'] = (LOG_keywords.MAIL_FROM.value)[loop_count]
    m['To'] = (LOG_keywords.MAIL_TO.value)[loop_count]
    server = smtplib.SMTP(host='smtp.gmail.com', port=587)
    server.starttls()
    server.login((LOG_keywords.MAIL_FROM.value)[loop_count],
                 (LOG_keywords.MAIL_PASSWORD.value)[loop_count])
    server.sendmail(m['From'], m['To'], m.as_string())
    server.quit()
コード例 #21
0
ファイル: views.py プロジェクト: jmjacquet/consorcios
def mandarEmailReserva(request, reserva):
    from smtplib import SMTP
    from email.mime.text import MIMEText as text
    try:
        sitio = gg_configuracion.objects.get(id=settings.MUNI_ID)
        email = sitio.email

    except gg_configuracion.DoesNotExist:
        sitio = None

    if not email:
        email = '*****@*****.**'
    to_addr = reserva.id_propietario.email
    if to_addr is None:
        return ''
    if to_addr == '':
        return ''
    cancha = reserva.id_cancha
    from_addr = email
    msg = u'Mail recordatorio de su reserva el día %s.\nCancha: %s - %s .\nTurno: %s hs. a %s hs.\nAnte cualquier inconveniente y/o cancelación comuníquese con Administración.\nAtte. Administración Aires del Llano.' % (
        reserva.fecha, cancha, cancha.get_tipo_display(),
        reserva.hora_inicio.hour, reserva.hora_fin.hour)

    m = text(msg.encode('utf-8'))

    m['Subject'] = 'Reserva Canchas (Sistema AutoGestión OnLine)'
    m['From'] = email
    m['To'] = to_addr
    s = SMTP()
    s.connect('smtp.webfaction.com')
    s.login(str('grupogua_juanmanuel'), str('qwerty'))
    s.sendmail(email, to_addr, m.as_string())
    message = "Se envío correctamente el email con la reserva."
    return message
コード例 #22
0
ファイル: event.py プロジェクト: ljb-2000/netman
	def sendNotify(self):
		'''sends message to subscriber(s)'''
		subject = '[%s] %s'  % (self.Severity2Word(self.Severity),self.Name)
		if self.Status == 3:
			subject = "Clear: %s" % subject
		headers = "FROM: %s <%s>\r\n" % (self.config.sitename,self.config.mailfrom)
		headers += "Subject: %s \r\n" % (subject)
		headers += "MIME-Version: 1.0\r\n"
		headers += "Content-Type: text/html; charset=ISO-8859-1\r\n"
		Data = ''' 

Device
Name: {DeviceName}
Address: {DeviceAddress}
Class: {DeviceClassName}
Layer: {DeviceLayer}
Production State: {DeviceState}

Event
Event-id: {EventId}
Status: {EventStatus}
Severity: {EventSeverity}
Source: {EventSource}
Tag: {EventTag}
First Seen: {EventFirstSeen}
Last Seen: {EventLastSeen}

Message
{EventMessage}


'''.format(
	DeviceName=self.Name,
	DeviceAddress=self.ipAddress(self.Address),
	DeviceClassName=self.ClassName,
	DeviceLayer=self.Layer,
	DeviceState=self.State,
	EventId=self.Eventid,
	EventStatus=self.Status2Word(self.Status),
	EventSeverity=self.Severity2Word(self.Severity),
	EventSource=self.Source,
	EventTag=self.Tag,
	EventFirstSeen=time.ctime(self.FirstSeen),
	EventLastSeen=time.ctime(self.LastSeen),
	EventMessage=self.Message,
)
		if self.Status == 3:
			Data += "Cleared by: %s" % self.ClearedBy
		
		Msg = text(Data)
		Msg['Subject'] = subject
		Msg['From'] = "%s <%s>" % (self.config.sitename,self.config.mailfrom)
		try:
			s = smtplib.SMTP('localhost')
			s.sendmail(self.config.mailfrom,list(set(self.Subscribers)),Msg.as_string())
			s.quit()
			
		except:
			self.log("unable to send message",0)
コード例 #23
0
def send(to, subject, content, file_name):
    """ Sends email using credectials passed as arguments """

    # Log file to keep track of events
    log_file = open("local/events.log", "a")

    try:
        # Main
        message = base()
        message["Subject"] = subject
        message["From"] = me
        message["To"] = to

        output = base()
        message.attach(output)

        # Attach content
        description = text(content, "html")
        output.attach(description)

        # For attachment
        if file_name != "":
            # This example assumes the image is in the current directory
            fp = open(file_name, "rb")
            attachment = img(fp.read())
            attachment.add_header('Content-ID', 'Attachment')
            output.attach(attachment)
            fp.close()

            # Log event
            log_file.write("%s emailed to %s at %s\n" %
                           (file_name[file_name.rfind("/") + 1:], to.strip(),
                            datetime.now().strftime('%I:%M:%S %p')))

        else:
            # Log event
            log_file.write(
                "Emailed to %s at %s\n" %
                (to.strip(), datetime.now().strftime('%I:%M:%S %p')))

        # Final send
        smtp = smtplib.SMTP("smtp.gmail.com",
                            587)  # Gmail smtp and port number

        # For authentication
        smtp.ehlo()
        smtp.starttls()
        smtp.ehlo
        smtp.login(me, me_pass)  # Login
        smtp.sendmail(me, to, message.as_string())  # Send email
        smtp.quit()

    except:
        # Log errors
        log_file.write("Unable to establish connection. Email not sent\n")

    log_file.close()
コード例 #24
0
def sendEmailToAlertUser(token, reason):
    c.execute("SELECT Email from Users WHERE ID = ?", (token, ))
    email = c.fetchone()[0]
    print(email + " " + reason)
    m = text(reason)
    m["Subject"] = "Stock Notifier"
    m["From"] = "*****@*****.**"
    m["To"] = email
    s.sendmail("*****@*****.**", email, m.as_string())
    return True
コード例 #25
0
def sendEmail(current_url):
    smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
    smtpObj.starttls()
    smtpObj.login('*****@*****.**', 'abcd6799')  #第一個參數是電郵帳號,第二個參數是密碼

    m = text("NTU Hospital eye department can be booked now\n" + current_url)
    m['Subject'] = 'NTU Hospital Booking Infrom!'
    m['From'] = "*****@*****.**"
    m['To'] = "*****@*****.**"

    smtpObj.sendmail(m['From'], m['To'], m.as_string())
コード例 #26
0
    def send_email_smtp(self, mail_server, mail_port,mail_user,mail_password,mail_starttls,mail_from,mail_to,mail_subject,mail_message):
        """
        Send email
        """
        # logger.debug(cl_fact_logger.get_instance().me())
        cl_fact_logger.get_instance().debug(cl_fact_logger.get_instance().me())
        
  
        crypt = cl_fact_help_crypt.get_instance()
        decrypted_secret = crypt.decrypt(mail_password).decode()

        cl_fact_logger.get_instance().debug('Server     =' + mail_server)
        cl_fact_logger.get_instance().debug('Port       =' + str(mail_port))
        cl_fact_logger.get_instance().debug('User       ='******'Password   ='******'Using SMTPSSL mode')
                server = SMTP_SSL(mail_server,mail_port)
            else:
                cl_fact_logger.get_instance().debug('Using plain SMTP mode')

                server = SMTP(mail_server,mail_port)
            
            server.ehlo()
            if mail_starttls == 1:
                server.starttls()
            
            server.login(mail_user,decrypted_secret)
            
    
            message = text(mail_message, 'plain', 'UTF-8')
    
            message['Subject'] = mail_subject
            message['From'] = mail_from
            message['To'] = mail_to
    
    
            server.sendmail(mail_from,mail_to, message.as_string())
            server.close()
            
            cl_fact_logger.get_instance().debug('Alert Email has been sent!')
        except SMTPException as cx_error:
            sending_error = 'Error: unable to send email: {err}'.format(err=cx_error)
            # logger.error(sendefehler)
            cl_fact_logger.get_instance().error(sending_error)
            
        except Exception as cx_error:
            #TODO err undefined!
            sending_error = 'Error: unable to send email: {err}'.format(err=cx_error)
            # logger.error(sendefehler)
            cl_fact_logger.get_instance().error(sending_error)
コード例 #27
0
ファイル: send_email.py プロジェクト: nttlong/gnol-xdj
def send_email(mail_to, subject, content):
    import smtplib, ssl
    load_settings()
    server = smtplib.SMTP(config.host, config.port)
    server.login(config.user, config.password)
    from email.mime.text import MIMEText as text
    m = text(content, 'html')
    m['Subject'] = subject
    m['Subject'] = 'Hello!'
    m['From'] = config.email
    m['To'] = mail_to
    return server.sendmail(config.email, mail_to, m.as_string())
コード例 #28
0
ファイル: Emergency.py プロジェクト: SRFG-MAT/RoboGen-QBO
def processEmergency(userName, emergencyMail):

    s = smtplib.SMTP('smtp.gmail.com', 587)
    s.starttls()
    s.login("*****@*****.**", "qboEmergencyPass321!")
    SUBJECT = "Notfall bei " + userName
    TEXT = "Notfall bei " + userName + "!\n\nSofort pruefen!"
    FROM = "QBO Mail"
    m = text(TEXT)
    m['Subject'] = SUBJECT
    m['From'] = FROM
    s.sendmail("*****@*****.**", emergencyMail, m.as_string())
    s.quit()
コード例 #29
0
ファイル: Notif.py プロジェクト: SRFG-MAT/RoboGen-QBO
def processNotif(userName, sentence, emergencyMail):

    s = smtplib.SMTP('smtp.gmail.com', 587)
    s.starttls()
    s.login("*****@*****.**", "qboEmergencyPass321!")
    SUBJECT = "Benachrichtigung von " + userName
    TEXT = "Benachrichtigung von " + userName + ":\n\n" + sentence
    FROM = "QBO Mail"
    m = text(TEXT)
    m['Subject'] = SUBJECT
    m['From'] = FROM
    s.sendmail("*****@*****.**", emergencyMail, m.as_string())
    s.quit()
コード例 #30
0
ファイル: sending.py プロジェクト: 12059976534/onlinebook
def kirim(p,s,t):
    import smtplib
    from email.mime.text import MIMEText as text

    server=smtplib.SMTP_SSL("smtp.gmail.com",465)  # inisualisasi objects smtplib (SMTP_SSL)
    server.login("*****@*****.**","sandi email ") # login ke email 

    m = text(p) # membuat teks message
    m['Subject'] = s # object messege to email

    # kirim email index[0] email pengirim,index[1] email penerima,index[2]pesan dan objeck 
    server.sendmail("*****@*****.**",t,m.as_string())
    # tutup server
    server.quit()
コード例 #31
0
ファイル: views.py プロジェクト: xzhaoCCHMC/motif-Z
def send_email(subject, message, sender,receiver):
    sender = sender
    receivers = receiver
    m = text(message)
    m['Subject'] = subject
    m['From'] = sender
    m['To'] = receiver

    try:
        smtpObj = smtplib.SMTP('localhost')
        smtpObj.sendmail(sender, receivers, str(m))
        print "Successfully sent email"
    except SMTPException:
        print "Error: unable to send email" 
コード例 #32
0
def send_email(pass_password, recivers, message, subject):
    port = 587
    smtp_server = "smtp.gmail.com"
    sender_email = "*****@*****.**"
    password = pass_password
    context = ssl.create_default_context()
    m = text(message)
    m['subject'] = subject
    m['from'] = sender_email
    with smtplib.SMTP(smtp_server, port) as server:
        server.ehlo()
        server.starttls(context=context)
        server.ehlo()
        server.login(sender_email, password)
        server.sendmail(sender_email, recivers, m.as_string().encode('utf8'))
コード例 #33
0
def send_email(smtp_host, smtp_user, smtp_pass, subject, to_address, msg):
    print "Sending e-mail to {}".format(to_address)

    # Setup SMTP server configuration
    server = smtplib.SMTP(smtp_host)
    server.starttls()
    server.login(smtp_user, smtp_pass)

    m = text(msg, 'html')
    m['Subject'] = subject
    m['From'] = smtp_user
    m['To'] = to_address

    server.sendmail(smtp_user, to_address, m.as_string())
    server.quit()
コード例 #34
0
    def message(self, to, msg):
        """ 
      Build the email alert 
      :param str to: email to receive alert 
      :param str msg: base message 
      :return: email to send
      """
        self.to = to
        self.msg = msg

        msg_ = text(HDR_MSG + '\n\n' + msg)
        msg_['From'] = self.s
        msg_['To'] = to
        msg_['Subject'] = "Coretemp Notification!"
        return msg_.as_string()
コード例 #35
0
ファイル: Exercise_4.py プロジェクト: JuveVR/Homework_6
def send_email(mail_domain, login, password, sender, recipient):
    """
    Send email from one email to another using following parameters
    :param mail_domain:email server domain name you want login to
    :param login: login name
    :param password: password
    :param sender: send from
    :param recipient: send to
    :return: None
    """
    with SMTP(mail_domain, 587) as smtp:
        smtp.starttls()
        smtp.login(login, password)
        m = text("I did it!")
        m["Subject"] = "Message from Vadym Rovenko"
        smtp.sendmail(sender,recipient, m.as_string())
コード例 #36
0
ファイル: emailstart.py プロジェクト: whtbowers/Willsite
def startalert(targadrs, randkey):

	fromaddr = "*****@*****.**"
	toaddrs  = targadrs
	subject = 'HAMSTR job is in progress'

	msg = text("Dear user, \n \n Your HAMSTR job has initiated. \n \n Unique key: " + randkey + ". \n \n Check on the status of your job by inputting your key at the following link: \n \n http://ld-mjeste10.bc.ic.ac.uk:8000/ \n \n Love HAMSTRbot \n \n \n ### THIS IS AN AUTOMATED EMAIL ###" )

	msg['Subject'] = subject
	msg['From'] = fromaddr
	msg['To'] = toaddrs

	server = smtplib.SMTP('localhost')
	server.set_debuglevel(1)
	server.sendmail(fromaddr, toaddrs, msg.as_string())
	server.quit()
コード例 #37
0
ファイル: email.py プロジェクト: vfabi/passreset
 def sendmail(self, resetlink, toemail):
     #server = smtplib.SMTP('smtp.gmail.com', 587)
     #server.starttls()
     #server.login('username', 'password')
     server = smtplib.SMTP_SSL(self.variables['EMAIL_SERVER_ADDRESS'],
                               self.variables['EMAIL_SERVER_PORT'])
     mail_text = EMAIL_BODY_TEMPLATE.format(
         resetlink=resetlink, signature=self.variables['app_name'])
     mail_body = text(mail_text)
     mail_body['Subject'] = self.subject
     mail_body['From'] = self.sender
     mail_body['To'] = toemail
     server.login(self.variables['EMAIL_SERVER_USER'],
                  self.variables['EMAIL_SERVER_PASSWORD'])
     server.sendmail(self.sender, toemail, mail_body.as_string())
     server.quit()
コード例 #38
0
 def sendEmail(self, subject, message):
     try:
         server = smtplib.SMTP(self.eServer)
         server.starttls()
         server.login(self.eFrom, self.eFromPassword)
         eMsg = text("FROM " + self.livDeviceName + "\n" + "\n" + "\n" +
                     message)
         eMsg['Subject'] = subject
         eMsg['From'] = self.eFrom
         eMsg['To'] = self.eToList
         server.sendmail(self.eFrom, self.eToList.split(','),
                         eMsg.as_string())
         server.quit()
         self.logger.info("LiV email sent")
     except:
         e = sys.exc_info()[0]
         self.logger.critical(e)
コード例 #39
0
def sendEmailToHost(host, port, sender, password, receiver, message = 'No message content.', subject = 'No subject'):
	try:
		mail = smtplib.SMTP(host, port)
		mail.ehlo()
		mail.starttls()
		mail.login(sender, password);
		msg = text(message)
		msg['Subject'] = subject
		mail.sendmail(sender, receiver, msg.as_string())      
		mail.close()
	except smtplib.SMTPRecipientsRefused:
		print 'Receipient refused to receive the message.'
	except smtplib.SMTPAuthenticationError:
		print 'User authentication error. \nServer did not accept username/password.'
	except smtplib.SMTPConnectError:
		print 'Unknown error while connecting to the host.'
	except Exception:
		print 'Unable to connect to the host. \nCheck the host address.'
コード例 #40
0
def send_mail(sender,receiver,subject, message, cc, bcc):
    sender = sender
    receivers = receiver
    m = text(message)
    m['Subject'] = subject
    m['From'] = sender
    m['To'] = receiver
    m['Cc'] = ','.join(cc)
    m['Bcc'] = ','.join(bcc)

   # message = message

    try:
       smtpObj = smtplib.SMTP('localhost')
       smtpObj.sendmail(sender, [receivers] + cc + bcc, str(m))
       print "Successfully sent email"
    except smtplib.SMTPException:
       print "Error: unable to send email" 
コード例 #41
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()
コード例 #42
0
ファイル: server.py プロジェクト: agscala/vgtourney_teaser
def send_feedback():
	user = "******"
	password = "******"

	receivers = ['*****@*****.**', '*****@*****.**']
	topic = 'Feedback - ' + request.forms.get('topic')
	email = request.forms.get('email') or "Anonymous"
	message = request.forms.get('message') + "\n\nSent by " + email

	content = text(message)
	content['Subject'] = topic

	smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
	smtpObj.starttls()
	smtpObj.login(user, password)

	smtpObj.sendmail(user, receivers, content.as_string())
	smtpObj.quit()
	return "success"
def send_email(receiver_email, message, subject=""):
	username = settings.EMAIL_HOST_USER
	password = settings.EMAIL_HOST_PASSWORD

	server = smtplib.SMTP(settings.EMAIL_HOST + ":" + str(settings.EMAIL_PORT))
	server.starttls()

	ntlm_authenticate(server, username, password)

	fromaddr = settings.DEFAULT_FROM_EMAIL
	toaddrs  = receiver_email

	m = text(message)

	m['Subject'] = subject
	m['From'] = fromaddr
	m['To'] = toaddrs

	print server.sendmail(fromaddr, toaddrs, m.as_string())
	server.quit()
def send_email(receiver_email, message):
	username = SECURE_CONFIG.SUPPORT_EMAIL_USERNAME
	password = SECURE_CONFIG.SUPPORT_EMAIL_PASSWORD

	server = smtplib.SMTP('mail.dtu.dk:587')
	server.starttls()

	ntlm_authenticate(server, username, password)

	fromaddr = SECURE_CONFIG.SUPPORT_EMAIL_ADDRESS
	toaddrs = receiver_email

	m = text(message)

	m['Subject'] = 'Data export request'
	m['From'] = fromaddr
	m['To'] = toaddrs

	print server.sendmail(fromaddr, toaddrs, m.as_string())
	server.quit()
コード例 #45
0
if checkpoint:
    check = True
counter = 0
print check
if check:
    server.login("YOUREMAILADDRESS", "YOUREMAILPASSWORD")
    with open('Desktop/angelmortalfinal.csv' , 'w') as infile:
        writer = csv.writer(infile)
        for key, value in final.iteritems():
            temp = [el for el in value]
            temp[0] = temp[0].rstrip()
            temp.insert(0, key)
            writer.writerow(temp)

    for name, emailarr in final.iteritems():
        
        m = text(emailtemplate)
        sender = "YOUREMAILADDRESS"
        receipient = emailarr[0]
        m['From'] = sender
        m['To'] = receipient
        m['Subject'] = "Hall Production Angel-Mortal"
        server.sendmail(sender, [receipient], m.as_string())  

        print counter
        counter += 1
 
            
print "done"