Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
267303ad
Commit
267303ad
authored
Sep 09, 1997
by
Jeffrey Shell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed Name from MailForm to MailHost
Simplified interface -- removed built-in templates (for now)
parent
5e9ddc03
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
367 deletions
+12
-367
lib/python/Products/MailHost/MailForm.py
lib/python/Products/MailHost/MailForm.py
+0
-184
lib/python/Products/MailHost/__init__.py
lib/python/Products/MailHost/__init__.py
+12
-8
lib/python/Products/MailHost/addMailForm_form.dtml
lib/python/Products/MailHost/addMailForm_form.dtml
+0
-82
lib/python/Products/MailHost/mailForm.dtml
lib/python/Products/MailHost/mailForm.dtml
+0
-20
lib/python/Products/MailHost/manageMailForm.dtml
lib/python/Products/MailHost/manageMailForm.dtml
+0
-73
No files found.
lib/python/Products/MailHost/MailForm.py
deleted
100644 → 0
View file @
5e9ddc03
from
Globals
import
Persistent
,
HTMLFile
,
HTML
from
socket
import
*
import
Acquisition
,
sys
,
regex
,
string
#$Id: MailForm.py,v 1.4 1997/09/09 18:40:34 jeffrey Exp $
__version__
=
"$Revision: 1.4 $"
[
11
:
-
2
]
smtpError
=
"SMTP Error"
addForm
=
HTMLFile
(
'MailForm/addMailForm_form'
)
def
add
(
self
,
id
=
'mailForm'
,
title
=
'Some mail thing'
,
smtp_host
=
None
,
localhost
=
'localhost'
,
smtp_port
=
25
,
mailTemplate
=
None
,
errorTemplate
=
None
,
sentMailTemplate
=
None
,
REQUEST
):
' add a MailForm into the system '
i
=
MailForm
()
#create new mailform
i
.
id
=
id
#give it id
i
.
title
=
title
#title
i
.
_init
(
localHost
=
localhost
,
smtpHost
=
smtp_host
,
smtpPort
=
smtp_port
,
mailTemplate
=
mailTemplate
,
errorTemplate
=
errorTemplate
,
sentMailTemplate
=
sentMailTemplate
)
self
.
_setObject
(
id
,
i
)
#register it
return
self
.
manage_main
(
self
,
REQUEST
)
#and whatever this does.. :)
class
MailForm
(
Persistent
,
Acquisition
.
Implicit
):
'a mailform...?'
manage
=
HTMLFile
(
'MailForm/manageMailForm'
)
index_html
=
HTMLFile
(
'MailForm/mailForm'
)
icon
=
"MailForm/MailForm_icon.gif"
def
__init__
(
self
):
'nothing yet'
pass
def
_init
(
self
,
localHost
,
smtpHost
,
smtpPort
,
mailTemplate
,
errorTemplate
,
sentMailTemplate
):
self
.
localHost
=
localHost
self
.
smtpHost
=
smtpHost
self
.
smtpPort
=
smtpPort
self
.
mailTemplate
=
mailTemplate
self
.
errorTemplate
=
errorTemplate
self
.
sentMailTemplate
=
sentMailTemplate
def
manage_makeChanges
(
self
,
title
,
localHost
,
smtpHost
,
smtpPort
):
'make the changes'
self
.
title
=
title
self
.
localHost
=
localHost
self
.
smtpHost
=
smtpHost
self
.
smtpPort
=
smtpPort
return
(
'Changes made'
,
'Changes made...'
)
def
send
(
trueself
,
self
):
'uhh, sponges off the request and mails it..?'
if
trueself
.
REQUEST
.
has_key
(
'd_template'
):
mtemplate
=
getattr
(
self
,
trueself
.
REQUEST
[
'd_template'
])
else
:
mtemplate
=
getattr
(
self
,
trueself
.
mailTemplate
)
messageText
=
mtemplate
(
self
,
trueself
.
REQUEST
)
headers
,
message
=
decapitate
(
messageText
)
for
requiredHeader
in
(
'to'
,
'from'
,
'subject'
):
if
not
headers
.
has_key
(
requiredHeader
):
raise
MailFormError
,
"Message missing SMTP Header '%s'"
\
%
requiredHeader
SendMail
(
trueself
.
smtpHost
,
trueself
.
smtpPort
,
trueself
.
localHost
).
send
(
mfrom
=
headers
[
'from'
],
mto
=
headers
[
'to'
],
subj
=
headers
[
'subject'
],
body
=
messageText
)
return
getattr
(
self
,
self
.
sentMailTemplate
)(
self
,
self
.
REQUEST
,
messageText
=
message
)
def
trueSend
(
trueself
,
self
=
None
,
REQUEST
=
None
,
**
kw
):
if
REQUEST
:
kw
=
REQUEST
if
self
==
None
:
self
=
trueself
if
kw
.
has_key
(
'd_template'
):
mtemplate
=
getattr
(
self
,
kw
[
'd_template'
])
else
:
mtemplate
=
getattr
(
self
,
trueself
.
mailTemplate
)
messageText
=
mtemplate
(
self
,
kw
)
headers
,
message
=
decapitate
(
messageText
)
for
requiredHeader
in
(
'to'
,
'from'
,
'subject'
):
if
not
headers
.
has_key
(
requiredHeader
):
raise
MailFormError
,
"Message missing SMTP Header '%s'"
\
%
requiredHeader
SendMail
(
trueself
.
smtpHost
,
trueself
.
smtpPort
,
trueself
.
localHost
).
send
(
mfrom
=
headers
[
'from'
],
mto
=
headers
[
'to'
],
subj
=
headers
[
'subject'
],
body
=
messageText
)
return
getattr
(
trueself
,
trueself
.
sentMailTemplate
)(
self
,
kw
,
messageText
=
message
)
def
kwikHack
(
self
,
mfid
,
REQUEST
):
'quick and ugly hack to test da system'
jj
=
getattr
(
self
,
mfid
)
return
jj
.
trueSend
(
self
=
self
,
REQUEST
=
REQUEST
)
class
SendMail
:
def
__init__
(
self
,
smtpHost
,
smtpPort
,
localHost
=
"localhost"
):
self
.
conn
=
socket
(
AF_INET
,
SOCK_STREAM
)
self
.
conn
.
connect
(
smtpHost
,
smtpPort
)
self
.
conn
.
send
(
"helo "
+
localHost
+
"
\
r
\
n
"
)
self
.
_check
(
'220'
)
def
__del__
(
self
):
self
.
close
()
def
_check
(
self
,
lev
=
'250'
):
data
=
self
.
conn
.
recv
(
1024
)
if
data
[:
3
]
!=
lev
:
raise
smtpError
,
"Expected %s, got %s from SMTP"
%
(
lev
,
data
[:
3
])
def
send
(
self
,
mfrom
,
mto
,
subj
,
body
):
self
.
conn
.
send
(
"mail from:<%s>
\
n
"
%
mfrom
)
self
.
_check
()
if
type
(
mto
)
==
type
([
1
,
2
]):
for
person
in
mto
:
self
.
conn
.
send
(
"rcpt to:<%s>
\
n
"
%
person
)
self
.
_check
()
else
:
self
.
conn
.
send
(
"rcpt to:<%s>
\
n
"
%
mto
)
self
.
_check
()
self
.
conn
.
send
(
"data
\
n
"
)
self
.
_check
()
self
.
conn
.
send
(
body
)
self
.
conn
.
send
(
"
\
n
.
\
n
"
)
self
.
_check
(
'354'
)
def
_close
(
self
):
self
.
conn
.
send
(
"quit
\
n
"
)
self
.
conn
.
close
()
def
decapitate
(
message
,
header_re
=
regex
.
compile
(
'
\
(
\
('
'[^
\
0
- <>:]+:[^
\
n
]*
\
n
'
'
\
|
'
'
[
\
t
]
+
[
^
\
0
-
][
^
\
n
]
*
\
n
'
'
\
)
+
\
)[
\
t
]
*
\
n
\
([
\
0
-
\
377
]
+
\
)
'
),
space_re=regex.compile('
\
([
\
t
]
+
\
)
'),
name_re=regex.compile('
\
([
^
\
0
-
<>
:]
+
\
):
\
([
^
\
n
]
*
\
)
'),
):
if header_re.match(message) < 0: return message
headers, body = header_re.group(1,3)
headers=string.split(headers,'
\
n
')
headerDict={}
i=1
while i < len(headers):
if not headers[i]:
del headers[i]
elif space_re.match(headers[i]) >= 0:
headers[i-1]="%s %s" % (headers[i-1],
headers[i][len(space_re.group(1)):])
del headers[i]
else:
i=i+1
for i in range(len(headers)):
if name_re.match(headers[i]) >= 0:
k, v = name_re.group(1,2)
k=string.lower(k); v=string.strip(v)
headerDict[k]=v
else:
raise ValueError, '
Invalid
Header
(
%
d
):
%
s
' % (i,headers[i])
if headerDict.has_key('
to
'):
headerDict['
to
']=map(
lambda x: string.strip(x),
string.split(headerDict['
to
'], '
,
')
)
return headerDict, body
#$Log: MailForm.py,v $
#Revision 1.4 1997/09/09 18:40:34 jeffrey
#updated with icon
#
\ No newline at end of file
lib/python/Products/MailHost/__init__.py
View file @
267303ad
...
...
@@ -7,22 +7,26 @@
# rights reserved.
#
##############################################################################
__doc__
=
'''Mail
Form
Product Initialization
$Id: __init__.py,v 1.
2 1997/09/09 16:09:13
jeffrey Exp $'''
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__doc__
=
'''Mail
Host
Product Initialization
$Id: __init__.py,v 1.
3 1997/09/09 20:49:16
jeffrey Exp $'''
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
import
Mail
Form
import
Mail
Host
__
.
meta_types
=
{
'name'
:
'Mail
Form
'
,
'action'
:
'manage_addMail
FormF
orm'
__
.
meta_types
=
{
'name'
:
'Mail
Host
'
,
'action'
:
'manage_addMail
Host_f
orm'
},
__
.
methods
=
{
'manage_addMail
FormForm'
:
MailForm
.
addForm
,
'manage_addMail
Form'
:
MailForm
.
add
,
'manage_addMail
Host_form'
:
MailHost
.
addForm
,
'manage_addMail
Host'
:
MailHost
.
add
,
}
#$Log: __init__.py,v $
#Revision 1.3 1997/09/09 20:49:16 jeffrey
#Changed Name from MailForm to MailHost
#Simplified interface -- removed built-in templates (for now)
#
#Revision 1.2 1997/09/09 16:09:13 jeffrey
#minor fixings
#
lib/python/Products/MailHost/addMailForm_form.dtml
deleted
100644 → 0
View file @
5e9ddc03
<HTML>
<HEAD>
<TITLE>Add a MailForm</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>Add a MailForm</H1>
<FORM ACTION="<!--#var PARENT_URL-->/manage_addMailForm" METHOD="POST">
<TABLE CELLSPACING="2">
<!--#var smallRolesWidget-->
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Id</B></TD>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="id" SIZE="50" value="MailForm">
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Title</B></TD>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="title" SIZE="50">
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Local Host</B></TD>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="localhost" SIZE="50" VALUE="localhost">
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>SMTP Host</B></TD>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="smtp_host" SIZE="50">
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>SMTP Port</B></TD>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="smtp_port:int" SIZE="4" VALUE="25">
</TD>
</TR>
<TR VALIGN="TOP">
<TD BGCOLOR="#555555" COLSPAN=2> </TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Mail template: </B></TD>
<TD ALIGN="LEFT">
<SELECT NAME="mailTemplate" SIZE=1>
<!--#in documentIds-->
<OPTION><!--#var sequence-item--></OPTION>
<!--#endin documentIds-->
</SELECT>
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Error template: </B></TD>
<TD ALIGN="LEFT">
<SELECT NAME="errorTemplate" SIZE=1>
<!--#in documentIds-->
<OPTION><!--#var sequence-item--></OPTION>
<!--#endin documentIds-->
</SELECT>
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Sent-mail template: </B></TD>
<TD ALIGN="LEFT">
<SELECT NAME="sentMailTemplate" SIZE=1>
<!--#in documentIds-->
<OPTION><!--#var sequence-item--></OPTION>
<!--#endin documentIds-->
</SELECT>
</TD>
</TR>
<TR VALIGN="TOP">
<TD> </TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add MailForm"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
lib/python/Products/MailHost/mailForm.dtml
deleted
100644 → 0
View file @
5e9ddc03
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN">
<HTML>
<HEAD>
<TITLE>
MailForm:
<!--#var title-->
</TITLE>
</HEAD>
<BODY
BGCOLOR=
"#FFFFFF"
>
<TABLE>
<TR>
<TD
ALIGN=
RIGHT
><H3><I>
All about me:
</I></H3></TD>
</TR>
<TR>
<TD
BGCOLOR=
"#CCCCCC"
>
<B>
Title:
</B><FONT
COLOR=
"#CC0000"
>
<!--#var title-->
</FONT><BR>
<B>
Mail Host:
</B><FONT
COLOR=
"#CC0000"
>
<!--#var smtpHost-->
</FONT><BR>
<B>
Mail Port:
</B><FONT
COLOR=
"#CC0000"
>
<!--#var smtpPort-->
</FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
lib/python/Products/MailHost/manageMailForm.dtml
deleted
100644 → 0
View file @
5e9ddc03
<HTML>
<HEAD>
<TITLE>Manage a MailForm</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>Manage a MailForm</H1>
<FORM ACTION="<!--#var PARENT_URL-->/manage_makeChanges" METHOD="POST">
<TABLE CELLSPACING="2">
<!--#var smallRolesWidget-->
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Id</B></TD>
<TD ALIGN="LEFT">
<FONT COLOR="#CC0000"><!--#var id--></FONT>
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Title</B></TD>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="title" SIZE="50" VALUE="<!--#var title-->">
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Local Host</B></TD>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="localHost" SIZE="50" VALUE="<!--#var localHost-->">
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>SMTP Host</B></TD>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="smtpHost" SIZE=50 VALUE="<!--#var smtpHost-->">
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>SMTP Port</B></TD>
<TD ALIGN="LEFT">
<INPUT TYPE="TEXT" NAME="smtpPort:int" SIZE="4" VALUE="<!--#var smtpPort-->">
</TD>
</TR>
<TR VALIGN="TOP">
<TD BGCOLOR="#555555" COLSPAN=2> </TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Mail template: </B></TD>
<TD ALIGN="LEFT">
<!--#var mailTemplate-->
<A HREF="<!--#var URL2-->/<!--#var mailTemplate-->/manage">[manage]</A>
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Error template: </B></TD>
<TD ALIGN="LEFT">
<!--#var errorTemplate-->
<A HREF="<!--#var URL2-->/<!--#var errorTemplate-->/manage">[manage]</A>
</TD>
</TR>
<TR VALIGN="TOP">
<TD ALIGN="LEFT"><B>Sent Mail template: </B></TD>
<TD ALIGN="LEFT">
<!--#var sentMailTemplate-->
<A HREF="<!--#var URL2-->/<!--#var sentMailTemplate-->/manage">[manage]</A>
</TD>
</TR>
<TR VALIGN="TOP">
<TD> </TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Make changes"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment