Answer the question
In order to leave comments, you need to log in
Why does SMTPRecipientsRefused occur?
Hello! Here is the code:
import telebot
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import ssl
sender_email = "[email protected]"
password = "12345678AbC"
context = ssl.create_default_context()
msg = MIMEMultipart("alternative")
bot = telebot.TeleBot("1011976361:AAFJIZsT0ECNTHa_Kx6zB_tfDh8KzbwGZyA")
keyboard = telebot.types.ReplyKeyboardMarkup(True, True)
keyboard.row("Отправить письмо")
domen = "foo-example.com"
global link
link = ""
global receiver_email
receiver_email = ""
msg["Subject"] = "test"
msg["From"] = sender_email
msg["To"] = receiver_email
if link == "" and receiver_email == "":
@bot.message_handler(commands=['start'])
def hello(message):
bot.send_message(message.chat.id, "", reply_markup=keyboard)
@bot.message_handler(content_types=['text'])
def request_email(message):
if message.text.lower() == "отправить письмо":
bot_message = bot.send_message(message.chat.id, "Введите почту получателя!")
bot.register_next_step_handler(bot_message, check_email)
def check_email(message):
if "@" in message.text:
receiver_email = message.text
print(receiver_email)
bot_message = bot.send_message(message.chat.id, "")
bot.register_next_step_handler(bot_message, check_link)
else:
bot_message = bot.send_message(message.chat.id, 'В почте должен присутствовать знак "@"!')
bot.register_next_step_handler(bot_message, check_email)
print(receiver_email)
def check_link(message):
link = message.text
if domen in link:
bot_message = bot.send_message(message.chat.id, "Отправляю письмо!")
print(link)
part = MIMEText(html, "html")
msg.attach(part)
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server:
server.login(sender_email, password)
server.sendmail(
sender_email, receiver_email, msg.as_string()
)
else:
bot_message = bot.send_message(message.chat.id, "Домен недействителен!")
bot.register_next_step_handler(bot_message, check_link)
link = ""
print(link)
Answer the question
In order to leave comments, you need to log in
You can try this if you correctly understood the structure of the tables and linked them.
select t1.*, t2.in, t2.out, t2.move, t1.all + t2.in-t2.out-t2.move as endofday
from tab1 as t1 /*Дата | Проект | Кол-во сотрудников*/
join tab2 as t2 /*Дата | Проект | Пришло | Ушло | Перевелось*/
on t1.data = t2.data and t1.project = t2.project
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question