From f2ecccce4fff68e80a12d07153e98452deb5668e Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 7 Mar 2017 13:14:16 +0100 Subject: [PATCH] Improved NOTIFICATION_SMTP_MAILER.make (..) to support user:password@... Propage error in notification_chain_mailer. --- .../notification_chain_mailer.e | 15 +++++++++++++++ .../smtp/notification_smtp_mailer.e | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/library/runtime/process/notification_email/notification_chain_mailer.e b/library/runtime/process/notification_email/notification_chain_mailer.e index 844dc270..1bd937b0 100644 --- a/library/runtime/process/notification_email/notification_chain_mailer.e +++ b/library/runtime/process/notification_email/notification_chain_mailer.e @@ -50,9 +50,24 @@ feature -- Basic operation do if active.is_available then active.process_email (a_email) + import_errors (active) end if attached next as l_next and then l_next.is_available then l_next.process_email (a_email) + import_errors (l_next) + end + end + +feature {NONE} -- Errors + + import_errors (a_mailer: NOTIFICATION_MAILER) + do + if attached a_mailer.last_errors as errs then + across + errs as ic + loop + report_error (ic.item) + end end end diff --git a/library/runtime/process/notification_email/smtp/notification_smtp_mailer.e b/library/runtime/process/notification_email/smtp/notification_smtp_mailer.e index 21f8b99d..ca096f4e 100644 --- a/library/runtime/process/notification_email/smtp/notification_smtp_mailer.e +++ b/library/runtime/process/notification_email/smtp/notification_smtp_mailer.e @@ -21,8 +21,21 @@ create feature {NONE} -- Initialization make (a_smtp_server: READABLE_STRING_8) + -- Create with smtp setting `user:password@hostname:port". + local + p,q: INTEGER do - make_with_user (a_smtp_server, Void, Void) + p := a_smtp_server.index_of ('@', 1) + if p > 0 then + q := a_smtp_server.index_of (':', 1) + if q < p then + make_with_user (a_smtp_server.substring (p + 1, a_smtp_server.count), a_smtp_server.substring (1, q -1), a_smtp_server.substring (q + 1, p -1)) + else + make_with_user (a_smtp_server.substring (p + 1, a_smtp_server.count), a_smtp_server.substring (1, p -1), Void) + end + else + make_with_user (a_smtp_server, Void, Void) + end end make_with_user (a_smtp_server: READABLE_STRING_8; a_user: detachable READABLE_STRING_8; a_password: detachable READABLE_STRING_8)