예제 #1
0
def newsletter_sub():

    # Send an email to subscribers
    if request.method == "POST":
        recipient = request.form["email"]
        message = f"Subject:Welcome to the Neswletter\n\nThank you for taking the time to register for our Newsletter.\n" \
                  f"We will be sending out a recap of any new features and updates to existing ones from time to time 😉."
        send_email(recipient, message.encode("utf8"))

        return redirect(url_for("home"))
예제 #2
0
async def price_edit(message: types.Message, state: FSMContext):
    recipient = message.text
    send_email(recipient)

    await state.finish()

    await bot.send_message(
        message.from_user.id,
        text='Благодарю за работу!',
    )
예제 #3
0
def send_message():

    # Send myself the message users are submitting
    if request.method == "POST":
        recipient = GMAIL_ACCOUNT
        message = f"Subject:{request.form['subject']}\n\n{request.form['name']} sent a message:\n{request.form['message']}.\n"\
                  f"Send reply to {request.form['email']}."
        send_email(recipient, message.encode("utf8"))
        flash("Message Successfully Sent! Thank you!")
        return redirect(url_for("home", _anchor="footer"))
    return redirect(url_for("home"))
예제 #4
0
def remind_pass(request):
    # if this is a POST request we need to process the form data
    if request.method == 'POST':
        # create a form instance and populate it with data from the request:
        form = RemainForm(request.POST)
        # check whether it's valid:
        if form.is_valid():
            # process the data in form.cleaned_data as required
            message = form.cleaned_data['message']
            try:
                user = User.objects.get(username=str(message))
                send_email(str(user.email), str(user.password))
                return redirect('/')
            except User.DoesNotExist:
                return redirect('/')

    # if a GET (or any other method) we'll create a blank forms
    else:
        form = RemainForm()

    return render(request, 'registration/remain_pass.html', {'formset': form})
예제 #5
0
def SaveDetail(user, email, pwd, con_pwd, root):
    if user != "":
        if email != "":
            if pwd == con_pwd and pwd != "":
                details = [user, email, pwd]
                m = random.randint(1000, 10000)
                subject = "OTP"
                msg = str(m)
                if send_email(subject, msg, email, details):
                    login(root)
            else:
                messagebox.showerror(' Failed', "Password doesn't match")
        else:
            messagebox.showerror(' Failed', "Enter email Field")
    else:
        messagebox.showerror(' Failed', "Enter User Name")
def submit_email():
    """
    "/submit-email" receive an email address from the form and send it.
    """
    if request.method == "POST":
        receiver_email = request.form["email"]
        try:
            # Try to send the email with the current_dataset.
            email_status = functions.send_email(receiver_email,
                                                current_dataset)
        except ValueError:
            return "False"

        # If successful, return True, else False.
        if email_status:
            return "True"
        return "False"
예제 #7
0
파일: main.py 프로젝트: NaumYegor/cashflow
def sign_up():

    user = {
        "login": request.values.get("login"),
        "email": request.values.get("email"),
        "password": request.values.get("password"),
        "token": urandom(16).hex(),
        "status": "inactive",
        "balance": 0
    }

    if not user["login"] or not user["email"] or not user["password"]:
        return "Not filled fields."

    conn = sqlite3.connect(constant.DB_NAME)
    cursor = conn.cursor()

    cursor.execute('SELECT * FROM users WHERE login=?', (user["login"], ))
    if cursor.fetchone() is not None:
        return "Try another login."

    cursor.execute('SELECT * FROM users WHERE email=?', (user["email"], ))
    if cursor.fetchone() is not None:
        return "Try another email."

    if not functions.log_pass_valid(user["login"], user["password"]):
        return functions.invalid_data_msg()

    try:
        if not functions.send_email(user["email"], user["token"]):
            return "Wrong email, bro."
    except UnicodeEncodeError:
        return "UnicodeEncodeError"

    user["password"] = bcrypt.hashpw(user["password"].encode('utf-8'),
                                     bcrypt.gensalt())
    user = functions.dict_to_tuple(user)
    print(user)
    cursor.execute("INSERT INTO users VALUES (?, ?, ?, ?, ?, ?)", user)
    conn.commit()
    conn.close()

    return "Check an email."
예제 #8
0
def callback(ch, method, propieties, body):
    body_inf = eval(body.decode())
    type_message = "".join(sys.argv[1:]).lower()
    if type_message == 'debug':
        create_or_open_txt(body_inf['type_message'], body_inf['message'])
        send_email(body_inf['type_message'], body_inf['message'])

    elif type_message == 'info' and body_inf['type_message'] in [
            'debug', 'info', 'warning'
    ]:
        create_or_open_txt(body_inf['type_message'], body_inf['message'])
        send_email(body_inf['type_message'], body_inf['message'])

    elif type_message == 'warning' and body_inf['type_message'] in [
            'warning', 'error'
    ]:
        create_or_open_txt(body_inf['type_message'], body_inf['message'])
        send_email(body_inf['type_message'], body_inf['message'])

    elif type_message == 'error' and body_inf['type_message'] in ['error']:
        create_or_open_txt(body_inf['type_message'], body_inf['message'])
        send_email(body_inf['type_message'], body_inf['message'])

    print(f'[X] received {body}')
예제 #9
0
def main():
    """ Function main.  Watch for new online jobs on Wyzant.com.

    Parameters:
    Returns:
    """
    do_beep = f.get_boolean("Beep when new job found? ")
    do_email = f.get_boolean("Email when new job found? ")
    do_log = f.get_boolean("Save activity to log? ")
    print_jobs = f.get_boolean("Print jobs? ")
    while True:
        num_pages = input("Number of job pages to read (1 or 2)? ")
        if num_pages in {"1", "2"}:
            num_pages = int(num_pages)
            break

    # On Exception, come back to here and re-initialize everything.
    while True:
        try:
            # Jobs dicts, stores info about job listings.
            jobs = Jobs()
            jobs_prev = Jobs()

            # Check the version of chromedriver.exe, and update when needed.
            # Check_Chromedriver.driver_mother_path = r"C:\Program Files\WebDrivers"
            # Check_Chromedriver.main()

            # stdout.write("Done checking the version of chromedriver.exe.\n\n")

            # Open output file for appending.
            if do_log:
                outfile = open('log.txt', 'a')
            else:
                outfile = None

            stdout.write("Initializing Selenium.\n")
            my_selenium = MySelenium()
            stdout.write("Done initializing Selenium.\n")
            stdout.write("Logging into Wyzant.\n")
            my_selenium.website_login(c.USERNAME, c.PASSWORD, c.LOGIN_PAGE_URL,
                                      c.PRE_LOGIN_PAGE_TITLE,
                                      c.POST_LOGIN_PAGE_TITLE,
                                      c.USERNAME_FIELD_XPATH,
                                      c.PASSWORD_FIELD_XPATH,
                                      c.LOGIN_BUTTON_XPATH)
            stdout.write("Done logging into Wyzant.\n")
            stdout.write("Going to the Wyzant job listings page.\n")
            my_selenium.go_to_web_page(c.JOBS_PAGE_URL, By.CLASS_NAME,
                                       c.UI_PAGE_LINK)
            stdout.write("At Wyzant job listings page.\n")

            xpath = "//label[@for='lesson_type_online']"
            my_selenium.click_sleep_wait(xpath, c.SLEEP_TIME, By.CLASS_NAME,
                                         c.UI_PAGE_LINK)
            stdout.write("Fetched Wyzant jobs list.\n")

            # Loop forever.
            while True:
                my_selenium.force_refresh(By.CLASS_NAME, c.UI_PAGE_LINK)

                # Save jobs into jobs_prev.  Skip if job_ids empty due to faulty page load.
                if jobs.count_jobs() > 0:
                    jobs_prev = deepcopy(jobs)
                    jobs.reset()

                # Print and write to log file the current datetime.
                date_time = datetime.now().strftime("%Y/%m/%d %H:%M:%S")
                stdout.write(date_time + "  ")
                if do_log:
                    outfile.write(date_time + "\n")
                    outfile.flush()

                for page_num in range(1, num_pages + 1):
                    if num_pages == 2:
                        # Click back and forth between pages 1 and page 2.
                        xpath = f'//div[@role="navigation"]/a[text()="{page_num}"]'
                        pages = my_selenium.find_elements_by_xpath(xpath)
                        # print("selecting: " + pages[0].text)
                        pages[0].click()
                    # Each instance of class "academy-card" contains 1 job, 10 visible per page.
                    academy_cards = my_selenium.get_all_related_by_class(
                        "academy-card")

                    for card_num, card_obj in enumerate(academy_cards):
                        # Get Job listing URL.
                        job_url = card_obj.find_element_by_xpath(
                            './h3/a').get_attribute('href')
                        card_num_display = 10 * (page_num - 1) + card_num

                        # Save job properties.
                        params = dict()
                        params[c.JOB_ID] = int(job_url.split("/")[-1].strip())
                        params[c.CARD_NUMBER] = card_num_display
                        job_age_info = card_obj.find_element_by_xpath(
                            './div[1]/span[1]').text.strip()
                        if job_age_info == "No applications yet":
                            params[c.APPLICATIONS] = "N"
                            job_age_info = card_obj.find_element_by_xpath(
                                './div[1]/span[2]').text.strip()
                        else:
                            params[c.APPLICATIONS] = "Y"
                        params[c.JOB_AGE] = f.age_to_minutes(job_age_info)
                        params[
                            c.STUDENT_NAME] = card_obj.find_element_by_xpath(
                                './p[1]').text.strip()
                        params[c.JOB_TOPIC] = card_obj.find_element_by_xpath(
                            './h3/a').text.strip()
                        pay_rate = card_obj.find_element_by_xpath(
                            './div[3]/span/div/div[1]/span').text.strip()
                        params[c.PAY_RATE] = pay_rate.replace(
                            "Recommended rate: ", "")
                        params[
                            c.
                            JOB_DESCRIPTION] = card_obj.find_element_by_xpath(
                                './p[2]').text.strip()

                        # Does "Show Details" control exist?
                        show_details = card_obj.find_elements_by_xpath(
                            './div[4]/div/div/p')
                        if len(show_details) == 1:
                            # If "Show Details" exists, click it.
                            show_details[0].click()

                            # Each instance of class "spc_zero" contains one job attribute.
                            spc_zeros = card_obj.find_elements_by_class_name(
                                "spc-zero")

                            # Iterate over all job attributes in class "spc_zero".
                            for spc_zero in spc_zeros:
                                # There are 1-2 children of class "spc_zero".
                                children = spc_zero.find_elements_by_xpath(
                                    './child::*')
                                if len(children) == 2:
                                    # Job attribute in 2nd child of class "spc_zero".
                                    value = spc_zero.find_element_by_xpath(
                                        './span[2]').text.strip()
                                else:
                                    # Sometimes the job availability attribute isn't the 2nd child of class "spc_zero".
                                    xpath = './../p[@class="text-semibold spc-tiny"]'
                                    items = spc_zero.find_elements_by_xpath(
                                        xpath)
                                    value = "; ".join(
                                        [item.text for item in items]).strip()

                                # Job attribute in 1st child of class "spc_zero".
                                my_key = spc_zero.find_element_by_xpath(
                                    './span[1]').text
                                my_key = my_key.replace(":", "").strip()
                                params[my_key] = value
                            # Done iterating over all job attributes in class "spc_zero".

                        # Save job properties in new instance of class Jobs.
                        jobs.add_job(**params)

                        # Print progress, on just one line.
                        if card_num_display == 0:
                            stdout.write(
                                f"Done fetching job {card_num_display}")
                        else:
                            stdout.write(f", {card_num_display}")
                    # Done iterating over academy_cards.
                # Done iterating over pages.

                # After stdout.write, need to add newline.
                stdout.write("\n")

                # Look for new jobs.
                # Get job IDs in job_ids and not in job_ids_prev.
                current_num = jobs.count_jobs()
                previous_num = jobs_prev.count_jobs()
                # Skip if job_ids or job_ids_prev has too few entries (1st loop or faulty page load).
                if current_num <= 10 * (num_pages - 1):
                    stdout.write(f"Current  # Job IDs: {current_num}.\n")
                elif previous_num <= 10 * (num_pages - 1):
                    stdout.write(f"Previous # Job IDs: {previous_num}.\n")
                else:
                    job_ids_previous = jobs_prev.get_job_ids()
                    new_job_ids = jobs.get_new_job_ids(job_ids_previous)

                    # Iterate over all new job listings.
                    for job_id in new_job_ids:
                        # Collect job data.
                        email_subject = f"New job at www.wyzant.com/tutor/jobs/{job_id}"
                        job_summary, job_data, age = jobs.get_job_data(
                            email_subject + "\n", job_id)

                        if age <= 120:
                            # Make audible tone.
                            if do_beep:
                                Beep(6000, 1000)

                            # Send email.
                            if do_email:
                                f.send_email(c.SMTP_SERVER,
                                             c.SMTP_PORT,
                                             c.SMTP_PASSWORD,
                                             c.EMAIL_SENDER,
                                             c.EMAIL_RECIPIENT,
                                             subject=email_subject,
                                             body=job_data)

                            # Print the job data, write job summary to log file.
                            stdout.write(job_data)
                            if do_log:
                                outfile.write(job_summary + "\n")
                                outfile.flush()
                    # Done iterating over new_job_ids.

                if print_jobs and jobs is not None:
                    stdout.write("BEGIN PRINTING JOBS.\n")
                    stdout.write(str(jobs) + '\n')
                    stdout.write("DONE PRINTING JOBS.\n")

                # Wait some more, so that jobs page polled about every 30 seconds.
                sleep(20)
            # End of inner while loop.
        except Exception:
            # Print exception.
            f.print_stacktrace()
            # Close log file.
            if do_log:
                outfile.flush()
                outfile.close()
            # Make audible tone.
            if do_beep:
                Beep(1000, 1000)
            # Wait, in case of a web glitch.
            sleep(c.SLEEP_TIME)
예제 #10
0
import time
from functions import check_the_market, send_email

startTime = time.time()

message = check_the_market()

send_email(message)

stopTime = time.time()

print(stopTime - startTime)
예제 #11
0
 def obj_create(self, bundle, **kwargs):
     user_id = bundle.request.GET.get('user_id')
     send_to = bundle.data['email']
     send_email(user_id, send_to)
예제 #12
0
        logger.debug('record: ')
        logger.debug(record)
        return record

    def start(self):
        logger.info('spider is starting')
        if self.login():
            time.sleep(2)
            return self.get_waiting_record()
        return None


if __name__ == "__main__":
    zj_username = os.environ['ZJ_USERNAME']
    zj_pwd = os.environ['ZJ_PWD']
    logger.debug('using username(%s) and password (%s) to login zj-system' %
                 (zj_username, zj_pwd))
    spider = Spider(zj_username, zj_pwd)
    record = spider.start()

    if record:
        email_stmp_server = os.environ['EMAIL_SMTP_SERVER']
        email_sender = os.environ['EMAIL_SENDER']
        email_sender_pwd = os.environ['EMAIL_SENDER_PWD']
        email_receiver = os.environ['EMAIL_RECEIVER']
        logger.debug(
            'using stmp server (%s), sender email (%s), sender password (%s), receiver (%s)'
            % (email_stmp_server, email_sender, email_sender_pwd,
               email_receiver))
        send_email(email_stmp_server, email_sender, email_sender_pwd,
                   [email_receiver], record)
예제 #13
0
    qdata_dom = qdata_dom[column_order]
    # Generate sheet name
    sheet_name = dom.replace("www.", "").replace(".com", "").replace("/", "").replace("*", "").replace("?", "") \
     .replace(":", "").replace("[", "").replace("]", "")

    # Export the current table to the excel file
    qdata_dom.to_excel(xlwriter, sheet_name=sheet_name, index=True)

# Close the excel writer now all tabs are complete
xlwriter.close()

print("Step 3 Complete: Creation of excel file of data")

# Send the email to vickys team with the excel file
send_email(
    "*****@*****.**", "Affiliate Daily Data Dump",
    "Hi Vicky, this is the affiliate revenue data from yesterday backwards. Any issues please ask.",
    "./todays_excel_file/data_dump_" + current_timestamp + ".xlsx")

print("Step 4 Complete: Sending the email to Vicky")

# Send the email to vickys team with the excel file
send_email(
    "*****@*****.**", "Affiliate Daily Data Dump",
    "Hi Glenn, this is the affiliate revenue data from yesterday backwards. Any issues please ask.",
    "./todays_excel_file/data_dump_" + current_timestamp + ".xlsx")

print("Step 5 Complete: Sending the email to Glenn")

# Send the email to vickys team with the excel file
send_email(
    "*****@*****.**", "Affiliate Daily Data Dump",
 def send_mail(self):
     receiver_email = self.userNameEntry.get()
     name = self.nameEntry.get()
     functions.send_email(receiver_email, name)