전자 메일을 보내는 스크립트를 만들려고합니다. 그러나 줄 바꿈을하는 방법?SMTPLIB Python 3의 줄 바꿈
변경 msg = MIMEText(msginp)
msg=MIMEText(msginp,_subtype='plain',_charset='windows-1255')
에 참고 : 나는 다음을 시도 msginp가 입력 (msginp = input('Body? ')
)
는 사람이 줄 바꿈을 만드는 방법을 알고 있나요? 키보드의 enter
키와 마찬가지로?
내 코드는 다음과 같습니다
import smtplib
from email.mime.text import MIMEText
import getpass
smtpserverinp = input('What SMTP server are you using? (Look here for more information. https://sites.google.com/view/smtpserver) ')
usern = input('What is your email adderess? ')
p = getpass.getpass(prompt='What is your password? (You will not see that you are typing because it is a password) ')
subjectss = input('Subject? ')
msginp = input('Body? ')
toaddr = input('To who do you want to send it to? ')
msg = MIMEText(msginp)
msg['Subject'] = subjectss
msg['From'] = usern
msg['To'] = toaddr
s = smtplib.SMTP(smtpserverinp, 587)
s.starttls()
s.login(usern, p)
s.sendmail(usern, toaddr, msg.as_string())
s.quit()
감사합니다! 당신은 내가이 당신이 원하는 완전히 무엇 이었습니까하지만 난 전에 그것을주지 경우 댓글을보고 추가 할 수 없습니다
print("Body? ", end="")
lines = []
while True:
line = input("")
if not len(line):
break
lines.append(line)
print("\n".join(lines))
내가 터미널에서이 작업을 수행 할 수있는 솔직/쉬운 방법이 있다고 생각하지 않습니다이 당신의 msginp 및 MimeText는 교체합니다. [Tkinter] (https://docs.python.org/3/library/tk.html)와 같은 간단한 GUI 라이브러리를 살펴볼 차례입니다. – danidee
이미 Tkinter를 사용하고 있습니다. 하지만 tkinter로 변환하기 전에 터미널에서 해보고 싶습니다. –