Skip to content

Commit

Permalink
Item13936: Experimental: Allow From: address override
Browse files Browse the repository at this point in the history
Some email servers and email lists block messages that are from/to the
same adress.  In addition, as the WebMaster is often a "person", then it
is more appropriate to use an "agent" name for emails originated by the
server rathern than the webmaster.
  • Loading branch information
gac410 committed Nov 12, 2016
1 parent 5adc0a8 commit 5e586cb
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 20 deletions.
2 changes: 1 addition & 1 deletion MailerContrib/templates/mailnotify.tmpl
Expand Up @@ -67,7 +67,7 @@
%TEXTHEAD%
%TMPL:END%
--------------------------------
%TMPL:DEF{MailNotifyBody}%From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
%TMPL:DEF{MailNotifyBody}%From: %WIKIAGENTNAME% <%WIKIAGENTEMAIL%>
To: %EMAILTO%
Subject: %WIKITOOLNAME%.%WEB% - %MAKETEXT{"Automated notification of topic changes"}%
Auto-Submitted: auto-generated
Expand Down
2 changes: 1 addition & 1 deletion MailerContrib/templates/newsletter.tmpl
Expand Up @@ -2,7 +2,7 @@
Templates for the mails sent out by mailnotify for newsletters.
}%

%TMPL:DEF{"NEWS:header"}%From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
%TMPL:DEF{"NEWS:header"}%From: %WIKIAGENTNAME% <%WIKIAGENTEMAIL%>
To: %EMAILTO%
Subject: %WIKITOOLNAME% %WEB%.%TOPIC%
Auto-Submitted: auto-generated
Expand Down
9 changes: 9 additions & 0 deletions core/data/System/VarWIKIAGENTEMAIL.txt
@@ -0,0 +1,9 @@
%META:TOPICINFO{author="ProjectContributor" date="1478916373" format="1.1" version="1"}%
%META:TOPICPARENT{name="Macros"}%
---+ WIKIAGENTEMAIL -- From: email address in emails sent by Foswiki.
---++ Examples
* =%<nop>WIKIAGENTEMAIL%= expands to =%WIKIAGENTEMAIL%=
%STOPINCLUDE%
---++ Related
[[VarWIKIAGENTNAME][WIKIAGENTNAME]], [[VarWIKIWEBMASTER][WIKIWEBMASTER]], [[VarWIKIWEBMASTERNAME][WIKIWEBMASTERNAME]]

9 changes: 9 additions & 0 deletions core/data/System/VarWIKIAGENTNAME.txt
@@ -0,0 +1,9 @@
%META:TOPICINFO{author="ProjectContributor" date="1478916373" format="1.1" version="1"}%
%META:TOPICPARENT{name="Macros"}%
---+ WIKIAGENTNAME -- From: Name used in emails sent by %WIKITOOLNAME%
---++ Examples
* =%<nop>WIKIAGENTNAME%= expands to =%WIKIAGENTNAME%=
%STOPINCLUDE%
---++ Related
[[VarWIKIAGENTEMAIL][WIKIAGENTEMAIL]], [[VarWIKIWEBMASTER][WIKIWEBMASTER]], [[VarWIKIWEBMASTERNAME][WIKIWEBMASTERNAME]]

4 changes: 4 additions & 0 deletions core/lib/Foswiki.pm
Expand Up @@ -419,6 +419,10 @@ BEGIN {
$macros{WIKIUSERSTOPIC} = sub { $Foswiki::cfg{UsersTopicName} };
$macros{WIKIWEBMASTER} = sub { $Foswiki::cfg{WebMasterEmail} };
$macros{WIKIWEBMASTERNAME} = sub { $Foswiki::cfg{WebMasterName} };
$macros{WIKIAGENTEMAIL} =
sub { $Foswiki::cfg{WikiAgentEmail} || $Foswiki::cfg{WebMasterEmail} };
$macros{WIKIAGENTNAME} =
sub { $Foswiki::cfg{WikiAgentName} || $Foswiki::cfg{WebMasterName} };

# locale setup
#
Expand Down
20 changes: 16 additions & 4 deletions core/lib/Foswiki.spec
Expand Up @@ -1798,14 +1798,26 @@ $Foswiki::cfg{WebMasterName} = 'Wiki Administrator';
# title='Long running: Probes the possible email servers to find most secure connection';\
# wizard='AutoConfigureEmail'; method='autoconfigure'"\
# FEEDBACK="icon='ui-icon-mail-closed';label='Send Test Email';wizard='SendTestEmail'; method='send'"**
# Wiki administrator (webmaster) e-mail address, used as the sender address
# in emails sent by Foswiki. For example =webmaster@example.com=
# Must be a single valid email address.
# This value is displayed using the =<nop>%WIKIWEBMASTER%= macro.
# Wiki administrator (webmaster) e-mail address. It's used as the "Contact" address on web pages and
# is also optionally used as the sender address in emails sent by Foswiki. For example =webmaster@example.com=
# If the Expert setting. ={WikiAgentEmail} is configured, it will be used as the From: address.
# Must be a single valid email address. This value is displayed using the =<nop>%WIKIWEBMASTER%= macro.
# <br/>
# If your server is already configured to send email, press Auto-configure email. If it works, email will be enabled. You can then send a test email to further verify operation.
$Foswiki::cfg{WebMasterEmail} = '';

# **STRING 30 LABEL="Wiki Agent Name" EXPERT**
# Used as part of the From: email address and defaults to ={WebMasterName}= if not configured.
# For use in mails sent by Foswiki. For example: "Wiki Gnome". This value is displayed using the
# =<nop>%WIKIAGENTNAME%= macro.
$Foswiki::cfg{WikiAgentName} = '';

# **EMAILADDRESS 30 LABEL="Wiki Agent Email" EXPERT**
# Email address used by Foswiki as the From: address for email messages, such as messages from the
# RegistrationAgent. The ={WebMasterEmail}= is used if this item is not configured.
# Configure this entry if your email server refuses to accept messages from and too the same address.
$Foswiki::cfg{WikiAgentEmail} = '';

# **STRING 30 LABEL="SMTP Host"\
# FEEDBACK="icon='ui-icon-mail-closed';label='Auto-configure Email';\
# title='Long running: Probes the possible email servers to find most secure connection';\
Expand Down
7 changes: 6 additions & 1 deletion core/lib/Foswiki/Configure/Wizards/SendTestEmail.pm
Expand Up @@ -99,8 +99,13 @@ SMIME
my $smimePlainText = $smimeHTMLText;
$smimePlainText =~ s/<[^>]*>//g;

my $fromName = $Foswiki::cfg{WikiAgentName}
|| $Foswiki::cfg{WebMasterName};
my $fromAddr = $Foswiki::cfg{WikiAgentEmail}
|| $Foswiki::cfg{WebMasterEmail};

my $msg = << "MAILTEST";
From: "$Foswiki::cfg{WebMasterName}" <$Foswiki::cfg{WebMasterEmail}>
From: "$fromName" <$fromAddr>
To: $addrs
Subject: Test of Foswiki e-mail to $addrs
Auto-Submitted: auto-generated
Expand Down
2 changes: 2 additions & 0 deletions core/lib/Foswiki/Contrib/core/MANIFEST
Expand Up @@ -282,6 +282,8 @@ data/System/VarVAR.txt 0644
data/System/VarWEB.txt 0644
data/System/VarWEBLIST.txt 0644
data/System/VarWEBPREFSTOPIC.txt 0644
data/System/VarWIKIAGENTEMAIL.txt 0644
data/System/VarWIKIAGENTNAME.txt 0644
data/System/VarWIKIHOMEURL.txt 0644
data/System/VarWIKINAME.txt 0644
data/System/VarWIKIPREFSTOPIC.txt 0644
Expand Down
2 changes: 1 addition & 1 deletion core/templates/mailresetpassword.tmpl
@@ -1,4 +1,4 @@
%{ This is a default template }%From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
%{ This is a default template }%From: %WIKIAGENTNAME% <%WIKIAGENTEMAIL%>
To: %FIRSTLASTNAME% <%EMAILADDRESS%>
Subject: %MAKETEXT{"Foswiki password reset for [_1]" args="%WIKINAME%"}%
Auto-Submitted: auto-generated
Expand Down
4 changes: 2 additions & 2 deletions core/templates/registerapprove.tmpl
@@ -1,4 +1,4 @@
From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
From: %WIKIAGENTNAME% <%WIKIAGENTEMAIL%>
To: %EMAILADDRESS%
Subject: %MAKETEXT{"[_1] registration approval required" args="%WIKITOOLNAME%"}%
Auto-Submitted: auto-generated
Expand All @@ -11,4 +11,4 @@ Content-Transfer-Encoding: 8bit

%MAKETEXT{"To approve this registration, visit [_2]" args="'%APPROVALCODE%', %SCRIPTURL{"register"}%?action=approve;code=%APPROVALCODE%;referee=%REFEREE%"}%

%MAKETEXT{"To block this registration, visit [_2]" args="'%APPROVALCODE%', %SCRIPTURL{"register"}%?action=disapprove;code=%APPROVALCODE%;referee=%REFEREE%"}%
%MAKETEXT{"To block this registration, visit [_2]" args="'%APPROVALCODE%', %SCRIPTURL{"register"}%?action=disapprove;code=%APPROVALCODE%;referee=%REFEREE%"}%
4 changes: 2 additions & 2 deletions core/templates/registerconfirm.tmpl
@@ -1,4 +1,4 @@
%{ This is a default template }%From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
%{ This is a default template }%From: %WIKIAGENTNAME% <%WIKIAGENTEMAIL%>
To: %FIRSTLASTNAME% <%EMAILADDRESS%>
Subject: %MAKETEXT{"How to activate your [_1] registration" args="%WIKITOOLNAME%"}%
Auto-Submitted: auto-generated
Expand All @@ -11,4 +11,4 @@ Content-Transfer-Encoding: 8bit
%MAKETEXT{"You now need to verify your e-mail address. You can do so by entering [_1] in the form presented to you when this e-mail was sent, or by visiting [_2]" args="'%VERIFICATIONCODE%', %SCRIPTURL{"register"}%?action=verify;code=%VERIFICATIONCODE%"}%

%MAKETEXT{"Note:"}%
%MAKETEXT{"If you got this e-mail by mistake: Somebody ([_1]) registered at the [_2] site using your mail address [_3]. Contact [_4] if this is in error." args="%SPACEOUT{%FIRSTLASTNAME%}%, %WIKITOOLNAME%, %EMAILADDRESS%, %WIKIWEBMASTER%"}%
%MAKETEXT{"If you got this e-mail by mistake: Somebody ([_1]) registered at the [_2] site using your mail address [_3]. Contact [_4] if this is in error." args="%SPACEOUT{%FIRSTLASTNAME%}%, %WIKITOOLNAME%, %EMAILADDRESS%, %WIKIWEBMASTER%"}%
4 changes: 2 additions & 2 deletions core/templates/registerdenied.tmpl
@@ -1,4 +1,4 @@
From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
From: %WIKIAGENTNAME% <%WIKIAGENTNAME%>
To: %EMAILADDRESS%
Subject: %MAKETEXT{"[_1] registration denied" args="%WIKITOOLNAME%"}%
Auto-Submitted: auto-generated
Expand All @@ -10,4 +10,4 @@ Content-Transfer-Encoding: 8bit

%MAKETEXT{"[_1] denied the registration." args="%REFEREE%"}%

%FEEDBACK%
%FEEDBACK%
4 changes: 2 additions & 2 deletions core/templates/registerfailednotremoved.tmpl
@@ -1,4 +1,4 @@
%{ This is a default template }%From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
%{ This is a default template }%From: %WIKIAGENTNAME% <%WIKIAGENTEMAIL%>
To: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
Subject: %MAKETEXT{"[_1] - Registration failure for [_2] ([_3])" args="%WIKITOOLNAME%, %WIKINAME%, %EMAILADDRESS%"}%
Auto-Submitted: auto-generated
Expand All @@ -18,4 +18,4 @@ Content-Transfer-Encoding: 8bit

%MAKETEXT{"Saved to:"}%

%SCRIPTURL{"view"}%/%USERSWEB%/%WIKINAME%
%SCRIPTURL{"view"}%/%USERSWEB%/%WIKINAME%
4 changes: 2 additions & 2 deletions core/templates/registerfailedremoved.tmpl
@@ -1,4 +1,4 @@
%{ This is a default template }%From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
%{ This is a default template }%From: %WIKIAGENTNAME% <%WIKIAGENTEMAIL%>
To: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
Subject: %MAKETEXT{"[_1] - Registration failure for [_2] ([_3])" args="%WIKITOOLNAME%, %WIKINAME%, %EMAILADDRESS%"}%
Auto-Submitted: auto-generated
Expand All @@ -19,4 +19,4 @@ args="%WIKINAME%, %EMAILADDRESS%"}%

%MAKETEXT{"Saved to:"}%

%SCRIPTURL{"view"}%/%USERSWEB%/%WIKINAME%
%SCRIPTURL{"view"}%/%USERSWEB%/%WIKINAME%
4 changes: 2 additions & 2 deletions core/templates/registernotifyadmin.tmpl
@@ -1,4 +1,4 @@
%{ This is a default template }%From: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
%{ This is a default template }%From: %WIKIAGENTNAME% <%WIKIAGENTEMAIL%>
To: %WIKIWEBMASTERNAME% <%WIKIWEBMASTER%>
Subject: %MAKETEXT{"[_1] - Registration for [_2] ([_3])" args="%WIKITOOLNAME%, %WIKINAME%, %EMAILADDRESS%"}%
Auto-Submitted: auto-generated
Expand All @@ -16,4 +16,4 @@ Content-Transfer-Encoding: 8bit

%MAKETEXT{"Saved to:"}%

%SCRIPTURL{"view"}%/%USERSWEB%/%WIKINAME%
%SCRIPTURL{"view"}%/%USERSWEB%/%WIKINAME%

0 comments on commit 5e586cb

Please sign in to comment.