Created
April 11, 2015 13:24
-
-
Save GreeeenApple/7dfc6457ed6d17ba3c1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import telnetlib | |
import wx | |
HOST = "127.0.0.1" # hoge.jp | |
PORT = 25 # smtp | |
def click_post(event): | |
From_add = text1.GetValue().encode("utf-8") | |
To_add = text2.GetValue().encode("utf-8") | |
data = text3.GetValue().encode("utf-8") | |
try: | |
tel = telnetlib.Telnet(host=HOST, port=PORT) | |
tel.write("EHLO [127.0.0.1]\n") | |
tel.write("MAIL FROM:<" + From_add + ">\n") | |
tel.write("RCPT TO:<" + To_add + ">\n") | |
tel.write("DATA\n") | |
tel.write(data + "\n") | |
tel.write(".\n") | |
except: | |
frame.SetStatusText("------送信に失敗しました-----") | |
else: | |
frame.SetStatusText("------送信完了-----") | |
finally: | |
tel.write("QUIT") | |
if __name__ == "__main__": | |
app = wx.App() | |
frame = wx.Frame(None, wx.ID_ANY, "MAIL SENDER", size=(600,500)) | |
frame.CreateStatusBar() | |
root_panel = wx.Panel(frame, wx.ID_ANY) | |
s_text1 = wx.StaticText(root_panel,wx.ID_ANY,"FROM\t:") | |
text1 = wx.TextCtrl(root_panel, wx.ID_ANY, "") | |
s_text2 = wx.StaticText(root_panel,wx.ID_ANY,"TO\t\t:") | |
text2 = wx.TextCtrl(root_panel, wx.ID_ANY, "") | |
s_text3 = wx.StaticText(root_panel,wx.ID_ANY,"BODY\t:") | |
text3 = wx.TextCtrl(root_panel, wx.ID_ANY, "",style=wx.TE_MULTILINE, size=(100,100)) | |
s_text4 = wx.StaticText(root_panel,wx.ID_ANY,"") | |
button1 = wx.Button(root_panel,wx.ID_ANY,"送信", size=(100,100)) | |
button1.Bind(wx.EVT_BUTTON, click_post) | |
layout1 = wx.FlexGridSizer(4,2) | |
layout1.Add(s_text1, flag=wx.SHAPED|wx.ALIGN_LEFT) | |
layout1.Add(text1, flag=wx.GROW) | |
layout1.Add(s_text2, flag=wx.SHAPED|wx.ALIGN_LEFT) | |
layout1.Add(text2, flag=wx.GROW) | |
layout1.Add(s_text3, flag=wx.SHAPED|wx.ALIGN_LEFT) | |
layout1.Add(text3, flag=wx.GROW) | |
layout1.Add(s_text4, flag=wx.SHAPED|wx.ALIGN_LEFT) | |
layout1.Add(button1, flag=wx.GROW) | |
layout1.AddGrowableRow(2) | |
layout1.AddGrowableCol(1) | |
root_panel.SetSizer(layout1) | |
frame.Show() | |
app.MainLoop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment