Added usage of notification_email library.
Added CMS_SETUP.mailer Updated implementation of email_service to use notification_email library
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||||
<library name="i18n" location="$ISE_LIBRARY\library\i18n\i18n-safe.ecf"/>
|
<library name="i18n" location="$ISE_LIBRARY\library\i18n\i18n-safe.ecf"/>
|
||||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||||
|
<library name="notification_mailer" location="$ISE_LIBRARY\contrib\library\runtime\process\notification_email\notification_email-safe.ecf"/>
|
||||||
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty-safe.ecf" readonly="false"/>
|
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty-safe.ecf" readonly="false"/>
|
||||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
||||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||||
|
|||||||
1
cms.ecf
1
cms.ecf
@@ -22,6 +22,7 @@
|
|||||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
|
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
|
||||||
<library name="i18n" location="$ISE_LIBRARY\library\i18n\i18n.ecf"/>
|
<library name="i18n" location="$ISE_LIBRARY\library\i18n\i18n.ecf"/>
|
||||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
||||||
|
<library name="notification_mailer" location="$ISE_LIBRARY\contrib\library\runtime\process\notification_email\notification_email.ecf"/>
|
||||||
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty.ecf" readonly="false"/>
|
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty.ecf" readonly="false"/>
|
||||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
|
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
|
||||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||||
|
|||||||
@@ -8,5 +8,7 @@ name=Eiffel CMS
|
|||||||
email=your@email.com
|
email=your@email.com
|
||||||
theme=bootstrap
|
theme=bootstrap
|
||||||
|
|
||||||
[misc]
|
[mailer]
|
||||||
smtp=localhost
|
smtp=localhost:25
|
||||||
|
#sendmail=/usr/bin/sendmail
|
||||||
|
#output=@stderr
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
<library name="cms_app_env" location="..\app_env\app_env-safe.ecf"/>
|
<library name="cms_app_env" location="..\app_env\app_env-safe.ecf"/>
|
||||||
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
|
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
|
||||||
|
<library name="notification_mailer" location="$ISE_LIBRARY\contrib\library\runtime\process\notification_email\notification_email-safe.ecf"/>
|
||||||
<cluster name="src" location=".\" recursive="true"/>
|
<cluster name="src" location=".\" recursive="true"/>
|
||||||
</target>
|
</target>
|
||||||
</system>
|
</system>
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ class
|
|||||||
EMAIL_SERVICE
|
EMAIL_SERVICE
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
SHARED_ERROR
|
SHARED_ERROR
|
||||||
|
|
||||||
SHARED_LOGGER
|
SHARED_LOGGER
|
||||||
|
|
||||||
create
|
create
|
||||||
@@ -31,9 +31,7 @@ feature {NONE} -- Initialization
|
|||||||
do
|
do
|
||||||
admin_email := parameters.admin_email
|
admin_email := parameters.admin_email
|
||||||
|
|
||||||
-- Get local host name needed in creation of SMTP_PROTOCOL.
|
create {NOTIFICATION_SMTP_MAILER} mailer.make (parameters.smtp_server)
|
||||||
create l_address_factory
|
|
||||||
create smtp_protocol.make (parameters.smtp_server, l_address_factory.create_localhost.host_name)
|
|
||||||
set_successful
|
set_successful
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -43,7 +41,7 @@ feature {NONE} -- Initialization
|
|||||||
admin_email: IMMUTABLE_STRING_8
|
admin_email: IMMUTABLE_STRING_8
|
||||||
-- Site admin's email.
|
-- Site admin's email.
|
||||||
|
|
||||||
smtp_protocol: SMTP_PROTOCOL
|
mailer: NOTIFICATION_MAILER
|
||||||
-- SMTP protocol.
|
-- SMTP protocol.
|
||||||
|
|
||||||
feature -- Basic Operations
|
feature -- Basic Operations
|
||||||
@@ -60,38 +58,34 @@ feature -- Basic Operations
|
|||||||
|
|
||||||
send_message (a_from_address, a_to_address: READABLE_STRING_8; a_subjet: READABLE_STRING_GENERAL; a_content: READABLE_STRING_GENERAL)
|
send_message (a_from_address, a_to_address: READABLE_STRING_8; a_subjet: READABLE_STRING_GENERAL; a_content: READABLE_STRING_GENERAL)
|
||||||
local
|
local
|
||||||
l_email: EMAIL
|
l_email: NOTIFICATION_EMAIL
|
||||||
utf: UTF_CONVERTER
|
utf: UTF_CONVERTER
|
||||||
do
|
do
|
||||||
write_debug_log (generator + ".send_message: [from:" + a_from_address + ", to:" + a_to_address + ", subject:" + a_subjet + ", content:" + a_content)
|
write_debug_log (generator + ".send_message: [from:" + a_from_address + ", to:" + a_to_address + ", subject:" + a_subjet + ", content:" + a_content)
|
||||||
create l_email.make_with_entry (a_from_address, a_to_address)
|
create l_email.make (a_from_address, a_to_address, utf.escaped_utf_32_string_to_utf_8_string_8 (a_subjet) , utf.escaped_utf_32_string_to_utf_8_string_8 (a_content))
|
||||||
l_email.set_message (utf.escaped_utf_32_string_to_utf_8_string_8 (a_content))
|
l_email.add_header_line ("MIME-Version:1.0")
|
||||||
l_email.add_header_entry ({EMAIL_CONSTANTS}.H_subject, utf.escaped_utf_32_string_to_utf_8_string_8 (a_subjet))
|
l_email.add_header_line ("Content-Type: text/html; charset=utf-8")
|
||||||
l_email.add_header_entry ("MIME-Version:", "1.0")
|
|
||||||
l_email.add_header_entry ("Content-Type", "text/html; charset=utf-8")
|
|
||||||
send_email (l_email)
|
send_email (l_email)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
send_email (a_email: EMAIL)
|
send_email (a_email: NOTIFICATION_EMAIL)
|
||||||
-- Send the email represented by `a_email'.
|
-- Send the email represented by `a_email'.
|
||||||
local
|
local
|
||||||
l_retried: BOOLEAN
|
l_retried: BOOLEAN
|
||||||
do
|
do
|
||||||
if not l_retried then
|
if not l_retried then
|
||||||
write_information_log (generator + ".send_email Process send email.")
|
write_information_log (generator + ".send_email Process send email.")
|
||||||
smtp_protocol.initiate_protocol
|
mailer.process_email (a_email)
|
||||||
smtp_protocol.transfer (a_email)
|
|
||||||
smtp_protocol.close_protocol
|
|
||||||
write_information_log (generator + ".send_email Email sent.")
|
write_information_log (generator + ".send_email Email sent.")
|
||||||
if smtp_protocol.error then
|
if mailer.has_error then
|
||||||
set_last_error ("smtp_protocol reported an error", generator + ".send_email")
|
set_last_error ("smtp_protocol reported an error", generator + ".send_email")
|
||||||
else
|
else
|
||||||
set_successful
|
set_successful
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
write_error_log (generator + ".send_email Email not send " + last_error_message )
|
write_error_log (generator + ".send_email Email not send " + last_error_message)
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
set_last_error_from_exception (generator + ".send_email")
|
set_last_error_from_exception (generator + ".send_email")
|
||||||
|
|||||||
@@ -147,10 +147,45 @@ feature -- Access
|
|||||||
end
|
end
|
||||||
|
|
||||||
build_mailer
|
build_mailer
|
||||||
|
local
|
||||||
|
retried: BOOLEAN
|
||||||
|
f: FILE
|
||||||
do
|
do
|
||||||
to_implement ("Not implemented mailer")
|
if not retried then
|
||||||
|
if attached text_item ("mailer.smtp") as l_smtp then
|
||||||
|
create {NOTIFICATION_SMTP_MAILER} mailer.make (l_smtp)
|
||||||
|
elseif attached text_item ("mailer.sendmail") as l_sendmail then
|
||||||
|
create {NOTIFICATION_SENDMAIL_MAILER} mailer.make_with_location (l_sendmail)
|
||||||
|
elseif attached text_item ("mailer.output") as l_output then
|
||||||
|
if l_output.is_case_insensitive_equal ("@stderr") then
|
||||||
|
f := io.error
|
||||||
|
elseif l_output.is_case_insensitive_equal ("@stdout") then
|
||||||
|
f := io.output
|
||||||
|
else
|
||||||
|
create {PLAIN_TEXT_FILE} f.make_with_name (l_output)
|
||||||
|
if not f.exists then
|
||||||
|
f.create_read_write
|
||||||
|
f.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
create {NOTIFICATION_STORAGE_MAILER} mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (f))
|
||||||
|
else
|
||||||
|
create {NOTIFICATION_STORAGE_MAILER} mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (io.error))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
check valid_mailer: False end
|
||||||
|
-- FIXME: should we report persistent error message? If yes, see how.
|
||||||
|
create {NOTIFICATION_NULL_MAILER} mailer
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
retried := True
|
||||||
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
mailer: NOTIFICATION_MAILER
|
||||||
|
|
||||||
feature -- Access: storage
|
feature -- Access: storage
|
||||||
|
|
||||||
storage_drivers: STRING_TABLE [CMS_STORAGE_BUILDER]
|
storage_drivers: STRING_TABLE [CMS_STORAGE_BUILDER]
|
||||||
|
|||||||
@@ -113,6 +113,13 @@ feature -- Access: Theme
|
|||||||
theme_name: READABLE_STRING_32
|
theme_name: READABLE_STRING_32
|
||||||
-- theme name.
|
-- theme name.
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
mailer: NOTIFICATION_MAILER
|
||||||
|
-- Email processor.
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access: storage
|
feature -- Access: storage
|
||||||
|
|
||||||
storage_drivers: STRING_TABLE [CMS_STORAGE_BUILDER]
|
storage_drivers: STRING_TABLE [CMS_STORAGE_BUILDER]
|
||||||
|
|||||||
Reference in New Issue
Block a user