Tags:
create new tag
view all tags

SID-02144: Comment Plugin: Use emailto-parameter

Status: Answered Answered TWiki version: 6.0.1 Perl version: v5.18.2
Category: CategoryPlugins Server OS: 2.6.32.53-grsec-pvops-xen-x64 Last update: 5 years ago

We would like to use the emailto-parameter of the comment plugin, but it won't work. The Plugin produces comments in the topic as expected but the Wiki won't send E-Mails.

Other EMails are sent as usual, eg notifying Plugin

In the topic the code looks like this:

%COMMENT{type="below" emailto="axel.voigt@schul-support-service.de" button="Info jetzt eintragen"}%

We have enabled the feature and have set up "$TWiki::cfg{Plugins}{CommentPlugin}{EmailEnabled} = 1;".

Tried to attach full configuration, but it seems it cannot be openend. Could send it via email if requested.

Cannot find any hints in documentation, FAQ, logfiles or web.

Using TWiki since about 10 years, presently version 6.01

Any advice appreciated, thanks

Axel Voigt
Schul-Support-Service e.V.
Große Weidestraße 4-16, 28195 Bremen , Germany
Hotline: 0421-361-6600, Mo-Fr 7.30 - 15.30 Uhr
www.schul-support-service.de

-- Axel Voigt - 2016-01-05

Discussion and Answer

The bad news is: It works for me - so I can't just debug in my own system.

Don't worry about the configuration: I could read it, and it looks fine. But still you can help me help you:

  • If sending mail fails, then TWiki writes a log message about the error to its warn file (something like .../data/warn201601.txt). You might need to ask your hoster to get this file if you don't have direct access to the data directory.
  • This might be a dumb question, but: What "notifying Plugin" can send mail in your installation? The WebNotify mechanism is in core, and unfortunately there are so many parts in TWiki which send mails. They differ slightly with regards to the mail headers they create, so perhaps your mailhost (also provided by your hoster) needs a particular header which is not provided by CommentPlugin? If we know which mechanism works, we can stare at the sources and compare.

-- Harald Jörg - 2016-01-05

Thank you for your answer, Harald!

> If sending mail fails, then TWiki writes a log message about the error to its warn file (something like .../data/warn201601.txt).

I had checked that already. There is about one such file per month, and in the current one there is no entry concerning any mail sending.

> What "notifying Plugin" can send mail in your installation?

Yes, right, I meant the "Webnotify"-_mechanism_, which we use and is working properly all the time.

In ...TWiki/MailerContrib I read that the Notify Mails are created by the Skript /tools/mailnotify.

Would the trick be to make that skript work für the comment plugin as well?

On the other hand, we would like to have the Comment-Mails sent instantly at inserting the comment, not only once a day. But I could configure another cron job to do that frequently.

What about working with a template for the emailto-option that would configure the mails correctly?

cheers, Axel

PS: When I tried using the comment function in this topic it strangely put the text somewhere in my original post, so I put my reply here manually

-- Axel Voigt - 2016-01-05

I was not aware of the emailto=""" parameter of the COMMENT variable. FWIW, I have used the SendMailPlugin to send mail from a COMMENT - see details at SendMailPlugin

-- Peter Thoeny - 2016-01-07

Thanks a lot so far, the qestion is answered partly:

By incident I discovered that for the simple emailto-parameter I mentioned above to work you just have to install the SendMailPlugin!

So, the problem is solved actually. But the many options (eg customizing the email) of Peters solution are very interesting. But, the code in

https://twiki.org/cgi-bin/view/Sandbox/SendMailPluginDemo

does not seem to work fully.

I've got one topic now for the users containing the following code

and another Topic (SoftwareTeamCommentPluginTemplate) with the template code:

%TMPL:DEF{PROMPT:softwareteamcomment}%
<b>My favorite city:</b>
<noautolink>
<select name="vote">
<option value="">Select...</option>
<option>Amsterdam</option>
<option>Bern</option>
<option>London</option>
<option>New York</option>
<option>Rome</option>
<option>San Francisco</option>
<option>Tokyo</option>
<option>Zurich</option>
</select>
</noautolink>
<input %DISABLED% type="submit" value="%button|Vote%" class="twikiSubmit" />
<input type="hidden" name="sendmailaction" value="send" />
%TMPL:END%


%TMPL:DEF{OUTPUT:softwareteamcomment}%%POS:BEFORE%| %URLPARAM{ "vote" encode="safe" }% | %WIKIUSERNAME% | %SERVERTIME% |
%STARTSECTION{ type="expandvariables" }%%SENDMAIL{
 action="%URLPARAM{sendmailaction}%"
 from="$webmastername <$webmasteremail>"
 to="$username <$useremail>"
 cc="%WIKIWEBMASTER%"
 subject="Your vote on %WIKITOOLNAME%"
 text="Dear %WIKIUSERNAME%,

Thank you for your vote!
   * You selected: %URLPARAM{ "vote" encode="safe" }%

Best regards,
TWiki administrator team"
 onerror="| $error |||$n"
}%%ENDSECTION{ type="expandvariables" }%%TMPL:END%

But the output works only partly, it looks like this, see attachment, and no email is sent. Of course I have to define webmastername etc somewhere, but there is probably one serious syntax problem but I just can't find it!

  • output.jpg:
    output.jpg

Apart from that I corrected one small syntax error, the last "WIKINAME" must be a "WIKIUSERNAME".

Thank you.

-- Axel Voigt - 2016-01-08

Is the SendMailPlugin enabled properly? Check in the TWiki web's InstalledPlugins. Or add an empty "%SENDMAIL{ action="" }%" in a test topic to see if it expands to an empty "" string.

-- Peter Thoeny - 2016-01-09

Not working yet.

SendEMail is listed in InstalledPlugins and in the "plugin test" in SendEmailPlugin it says the plugin "is enabled".

In configure > "allowed mail adresses" I have set mail adresses and have activated ExpandVariablesInTemplate.

Adding %SENDMAIL{ action="" }% to a empty test topic only results in this code to be displayed, though I am not quite sure what is supposed to happen. I'm afraid I have not quite succeeded yet in fully understanding https://twiki.org/cgi-bin/view/TWiki06x00/TWikiTemplates#Variable_Expansion

thank you.

-- Axel Voigt - 2016-01-11

Please note that the SendMailPlugin and the SendEmailPlugin plugin are different plugins. You need the one without the E.

-- Peter Thoeny - 2016-01-11

Right, I am one step further now after installing the right plugin, thank you!

But, this Topic Code

%SENDMAIL{
 action="%IF{ "'%WIKINAME%'='AxelVoigt'" then="send"}%"
 subject="%TOPIC% Topic View, conditional"
 to="$webmasteremail"
 text="Viewed by %WIKINAME%"
}%

gets me this result

ERROR: Can't send mail, missing 'From:' at /kunden/183499_28195/webseiten/s3wiki/lib/TWiki/Net.pm line 608. Too many failures sending mail 

Seems I am too dumb to check out how to configure the plugin. I tried/checked

  • Net.pm line 608: nothing there that got me somewhere
  • configure > extensions: putting clear text mail adresses instead of the defaults
  • putting clear text mail adresses in the topic code
  • SendMailPlugin.pm
  • Config.spec
  • debugging the plugin with the output in debug.txt

Is it a problem of defining $webmastername, $webmasteremail, $username and $useremail ? Do I have to define which "mail-engine" is to be used?

Other Mail-Sending mechanisms / plugins still work nicely.

thank you for your patience.

-- Axel Voigt - 2016-01-14

Reading the code, the "From" is taken in this sequence:

  • $TWiki::cfg{Plugins}{SendMailPlugin}{From} configure setting
  • from parameter of SENDMAIL variable
  • $TWiki::cfg{WebMasterName} <$TWiki::cfg{WebMasterEmail}>

Turn on debug at $TWiki::cfg{Plugins}{SendMailPlugin}{Debug} and look at data/debug.txt

-- Peter Thoeny - 2016-01-14

I had tried debugging already but no matter what I do, the output (at least the interesting part, I think) is always about the same as the inline error text:

| 2016-01-18 - 17:17:13 | TWiki::Plugins::SendMailPlugin e-mail:
| 2016-01-18 - 17:17:13 | ===( START )=============
| 2016-01-18 - 17:17:13 | From: 
To: 
Subject: TestTopic2 Topic View, conditional
Content-Type: text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

SendMailPlugin Note: For e-mail body specify a text="..." parameter, and possibly a htmltext="..." parameter with HTML message.

| 2016-01-18 - 17:17:13 | ===(  END  )=============
| 2016-01-18 - 17:17:14 | TWiki::Plugins::SendMailPlugin e-mail error: ERROR: Can't send mail, missing 'From:' at /kunden/183499_28195/webseiten/s3wiki/lib/TWiki/Net.pm line 608. Too many failures sending mail

I have tried clear from mail adresses in $TWiki::cfg{Plugins}{SendMailPlugin}{From}= configure setting as well as in the code (then with empty "from configure" setting), I understand this is from parameter of SENDMAIL variable

If I leave both empty the plugin will not even read %WIKIWEBMASTER% which is interpreted correctly otherwise in the wiki, even in the same topic.

The plugin just does not seem to try to read the "from information" from anywhere (and not the "to information", either).

I suppose it's senseless to post our net.pm here as it's the same anywhere. But I tried to analyze in the net.pm where the problem might derive but to no avail.

thanks, Axel

-- Axel Voigt - 2016-01-17

I am still baffled that the plain emailto parameter just works in my installation, without having any other Send[E]MailPlugin installed, and that it doesn't even leave a warning line in your installation. Your debugging lines show that SendMailPlugin picks up the subject, but no other parameters (text apparently isn't recognized either) - but that is probably just coming from a test without any text.

But anyway, I could easily reproduce your failure to get SendMailPlugin to work. It's a bug in SendMailPlugin, introduced in August 2015. I'll file a bug report. Cross-check: It should work if you specify wiki names of registered users instead of mail addresses.

-- Harald Jörg - 2016-01-18

Cross-check negative: Using a wiki name does not work either. This code

%SENDMAIL{
 action="%IF{ "'%WIKINAME%'='AxelVoigt'" then="send"}%"
 subject="%TOPIC% Topic View, conditional"
 from:"AxelVoigt"
 to="AxelVoigt"
 text="Viewed by %WIKINAME%"
}%

produces the same lines in debug.txt as plain mail addresses.

text is not recognized, either.

btw: Using the same wiki name instead of a mail address in SendEmailTo plugin works as expected.

thanks for filing the bug report.

-- Axel Voigt - 2016-01-19

Erm.... please double-check: You wrote from:"AxelVoigt" where it should read from="AxelVoigt". A from: in the parameter list would also explain the missing from, and also why text isn't recognized, it confuses the attribute parser. I don't have any other explanation. All plugins and contribs are sending their mails through the same routine TWiki::Func::sendEmail, I've no clue whether it works with some callers and doesn't with others.

-- Harald Jörg - 2016-01-19

I fixed the bug Harald pointed out, the updated SendMailPlugin package is now available.

-- Peter Thoeny - 2016-01-20

  1. @Harald: sorry, syntax error there in the posting, but I tested before with correct syntax and it did not work.
  2. Success! but only partly.
    1. after updating the plugin it now reads wiki names and sends mails! These can be put in the code or in configure.
    2. but plain mail addresses and $webmasteremail etc are still not read, not in the code, not in configure. Same error output as before. This is for both my testing szenarios (Topic View conditional, city voting).

-- Axel Voigt - 2016-01-20

I'm out of ideas what's going on there. Cause and effect are always different than I'd expect. In my installation, wiki names have always worked, and plain mail addresses as well as the variables (like $webmasteremail) start to work with the updated plugin. But wait - there's another wild guess: Are you (or is your hoster) running a persistent interpreter like FGCI? In that case, after updating a plugin a restart of the interpreter (in case of FCGI, that is not the webserver!) is required to be sure that new software or config settings come into effect.

-- Harald Jörg - 2016-01-20

thanks for trying another guess, but there is no FGCI or such running, I checked with the webhoster.

Well, maybe others will work on this in the future and the mystery is solved some day. Anyway, we are happy, we can work with the comment plugin the way we wanted.

For readers of this topic here a conclusion:

  1. Using the emailto-parameter of the comment plugin was possible for us after installing the SendEmailPlugin (with "E"), no further configuring was necessary.
  2. Using a comment function with the SendMailPlugin (without "E") as described here https://twiki.org/cgi-bin/view/Plugins/SendMailPlugin#Send_E_mail_from_CommentPlugin_F worked in our TWiki with wiki names, such as AxelVoigt, bot not with plain mail addresses or variables.

-- Axel Voigt - 2016-01-28

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title Comment Plugin: Use emailto-parameter
SupportCategory CategoryPlugins
TWiki version 6.0.1
Server OS 2.6.32.53-grsec-pvops-xen-x64
Web server cannot find out right now, hosted service
Perl version v5.18.2
Browser & version

Topic attachments
I Attachment History Action Size Date Who Comment
HTMLhtm TWiki_Configuration.htm r1 manage 234.6 K 2016-01-05 - 18:59 UnknownUser  
JPEGjpg output.jpg r1 manage 96.7 K 2016-01-08 - 17:42 UnknownUser  
Edit | Attach | Watch | Print version | History: r20 < r19 < r18 < r17 < r16 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r20 - 2020-04-26 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.