1
매일 전자 메일을 에게 보낼 수있는 프로그램을 구현하고 싶습니다. 그리고 [email protected]처럼 효과를 만드십시오.
많은 솔루션을 시도했지만 이러한 솔루션은 작동하지 않습니다.
이 경험이있는 사람은 입니다. 해결책은입니다.
감사합니다.Exchange 서버 호스트 (outbound.company.com)를 사용하여 Linux에서 전자 메일을 보낼 수있는 프로그램을 구현하는 방법
my python code<br>
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# you == recipient's email address
me = "[email protected]"
you = "[email protected]"
# Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart('alternative')
msg['Subject'] = "Link"
msg['From'] = me
msg['To'] = you
# Create the body of the message (a plain-text and an HTML version).
text = "Hi!\nHow are you?\nHere is the link you wanted:\nhttp://www.python.org"
html = """\
<html>
<head></head>
<body>
<p>Hi!<br>
How are you?<br>
Here is the <a href="http://www.python.org">link</a> you wanted.
</p>
</body>
</html>
"""
# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')
# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
msg.attach(part1)
msg.attach(part2)
# Send the message via exchange sever SMTP server.
s = smtplib.SMTP('outbound.companyname.com')
# sendmail function takes 3 arguments: sender's address, recipient's address
# and message to send - here it is sent as one string.
s.sendmail(me, you, msg.as_string())
s.quit()
당신은 PHP가 필요하지 않습니다. 'crontab '항목이 필요하고 리눅스 서버에서 메일 링 서브 시스템을 적절하게 설정해야한다. –
@BasileStarynkevitch 귀하의 가이드를 보내 주셔서 감사합니다. {crontab}이 (가) 반복 작업을 수행 할 수 있음을 안다. 당신은 리눅스 서버에 메일 링 서브 시스템을 설정해야 함을 의미한다. 그 후, 보낸 전자 메일 프로그램을 구현하는 모범 사례가 있습니까? – andyqee
전자 메일을 보낼 여러 유틸리티와 라이브러리가 있습니다. (특히, 전체 MIME이 필요한지 아닌지, 즉 단일 일반 텍스트 만 보내면됩니까?) –