Question
I installed
MailerContrib for my Cairo installation and now receive the following error messages when I run the
/bin/mailnotify script from a Cygwin command line (no change notification e-mail is sent):
- Changed topics since 02 Mar 2006 - 18:42: WebNotify WebChanges
- Sending mail notification to: name@email.com
Use of unitialized value in concatenation (.) or string at c:/twiki/lib/TWiki/Net.pm line 156.
* ERROR: Can't send mail, missing 'From:'
- End TWiki.Main
Checking TWiki.Manuals
- Note: No topics changed since 02 Mar 2006 - 15:19
(where
name@email.com is my actual e-mail address)
Notes:
- From a Cygwin
/twiki/bin/ prompt, the command line I run is: c:/cygwin/bin/perl.exe -T mailnotify
- I'm using SMTPMAILHOST to send e-mail.
- The standard WebNotify function worked just fine prior to my installing MailerContrib.
- I downloaded the installation file for MailerContrib from here http://twiki.org/cgi-bin/view/Plugins/MailerContrib
, but followed the installation instructions from here: http://twiki.org/cgi-bin/view/Plugins/MailerContrib?rev=1.17
since I'm not running TWiki 4.0 (I'm running Cairo).
- The error appears for each web in which changes are detected.
- I installed MailerContrib because we want to generate per topic changes e-mail notification. I understand this add-on is standard with Dakar, but due to potential stability and compatibility issues between Dakar and the other plugins/add-ons that we want to use we're just not ready to upgrade - yet.
Thoughts?
Environment
--
JasonVensel - 06 Mar 2006
Answer
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.
The bin/mailnotify script
is the standard
WebNotify. The version of
MailerContrib you installed uses bin/mailnotifier.
--
CrawfordCurrie - 12 Mar 2006
I don't have a
/bin/mailnotifier/ file anywhere on my system. Moreover, I don't know where to find one - the plugin zip file attached to the TWiki.org
MailerContrib topic does NOT include such a file. Note that it DOES include a
/tools/mailnotify file.
Am I supposed to rename
/tools/mailnotify to
mailnotifier and then move it to
/twiki/bin?
--
JasonVensel - 13 Mar 2006
In addition, if I attempt to open or extract any version of the zip file OTHER THAN 1.11 (e.g., version 1.10, 1.9, 1.8) I receive the following
WinZip error: "Cannot open file: it does not appear to be a valid archive. If you downloaded this file, try downloading the file again."
--
JasonVensel - 13 Mar 2006
Jason, there is confusing since the zip attached to
MailerContrib is packaged for Dakar only and the link provided to earlier versions points to the latest Dakar zip. Please get the latest Cairo version from
http://twiki.org//cgi-bin/viewfile/Plugins/MailerContrib?rev=1.11&filename=MailerContrib.zip
, it contains the
mailnotifier script.
--
PeterThoeny - 13 Mar 2006
Peter, using the link you provided, I downloaded the MailerContrib.zip file. However, when I attempt to unzip the file, I receive the WinZip error: "Cannot open file: it does not appear to be a valid archive. If you downloaded this file, try downloading the file again."
If I attempt to unzip the file from a command line, I receive the following error: "End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive."
Please advise.
--
JasonVensel - 13 Mar 2006
Not sure what is wrong. Try the one I downloaded. I am able to unpack it (on Windows XP)
--
PeterThoeny - 13 Mar 2006
Not sure either. I'm able to unzip the one you attached below, though. I'll try to get this working and post my results later. Thanks!!
--
JasonVensel - 13 Mar 2006
Possibly a mime type issue if file delivered by
viewfile script instead of static content.
--
PeterThoeny - 13 Mar 2006
Update: I unzipped and installed the Cairo version of
MailerContrib without any problems. The problem now is that when I run the
mailnotifier script from a command line, I receive the same error I get when I run the
mailnotify script from a command line:
Use of uninitialized value in concatenation (.) or string at c:/twiki/lib/TWiki/Net.pm line 156.
**** ERROR :Mail send failed: ERROR: Can't send mail, missing 'From:'
Line 156 in my
Net.pm file is:
$theText = "$header\n\n$body"; # rebuild message
To provide a little context, line 156 appears among the following lines in my
Net.pm file:
# Send the email. Use Net::SMTP if it's installed, otherwise use a
# sendmail type program.
if( $useNetSmtp ) {
my ( $header, $body ) = split( "\n\n", $theText, 2 );
my @headerlines = split( /\n/, $header );
$header =~ s/\nBCC\:[^\n]*//os; #remove BCC line from header
$header =~ s/([\n\r])(From|To|CC|BCC)(\:\s*)([^\n\r]*)/$1 . $2 . $3 . _fixLineLength( $4 )/geois;
$theText = "$header\n\n$body"; # rebuild message
# extract 'From:'
my $from = "";
my @arr = grep( /^From: /i, @headerlines );
if( scalar( @arr ) ) {
$from = $arr[0];
$from =~ s/^From:\s*//io;
$from =~ s/.*<(.*?)>.*/$1/o; # extract "user@host" out of "Name <user@host>"
}
if( ! ( $from ) ) {
return "ERROR: Can't send mail, missing 'From:'";
}
Based on the output that appears in the Cygwin command line UI, both the
mailnotify and
mailnotifier scripts process the changes. The problem seems to lie with
Net.pm and SMTP mail handling.
I noticed the following lines in
Net.pm and wondered if I needed to set them to
1 to activate them, but it didn't seem to have any effect:
BEGIN {
$useNetSmtp = 0;
$mailInitialized = 0;
Note: The
mailnotify script was working at one point. I'm not sure what changed. I may have installed or updated the CPAN Net::SMTP module (if I'm looking in the right place, I appear to have version 2.29 installed - based on the
$VERSION value that appears inside my
c:/cygwin/lib/perl5/5.8/net/SMTP.pm file), but I don't know that this would be an issue because I believe I'm using SMTP (not sendmail). I am confident that my
TWikiPreferences topic and WebNotify topics are configured correctly.
Note: No errors appear in my Apache error log when I run the mail scripts.
Thoughts?
--
JasonVensel - 14 Mar 2006
Okay, my problem here occurs when I run either
c:/twiki/bin/mailnotify OR
c:/twiki/bin/mailnotifier. So the problem doesn't likely originate with those files. That means the problem likely exists in one of the other configuration files, for example:
-
c:/twiki/bin/setlib.cfg
-
c:/twiki/data/TWiki/TWikiPreferences.txt
-
c:/twiki/data/*/WebNotify.txt
-
c:/twiki/lib/TWiki.cfg
-
c:/twiki/lib/TWiki.pm
-
c:/twiki/lib/TWiki/Net.pm
-
c:/twiki/lib/TWiki/Prefs.pm
I don't think the problem originates from the
TWikiPreferences topic or any of the WebNotify topics.
In addition, because the error also appears for the standard
mailnotify script, the problem likely doesn't originate from any of the files located under
c:/twiki/lib/TWiki/Contrib.
--
JasonVensel - 15 Mar 2006
Important Note: E-mail notification of new registered users works. So it's just the change notifications that aren't working. Odd.
--
JasonVensel - 15 Mar 2006
I'm confident the issue is not related to the
Net.pm file. The basis for this belief is the result of two tests I performed:
- First, I replaced my existing
Net.pm file with the one included in the standard Cairo install files. I ran mailnotify against the standard Net.pm file and still got the same error.
- Second, I ran a similar test using the
Net.pm file from Bejing. I got the same concatenation error for the exact same line; it isn't line #156 in the Bejing version of the file, but the content of the line to which the error refers - $theText = "$header\n\n$body"; # rebuild message - is exactly the same.
Conclusion: My
Net.pm file is fine.
--
JasonVensel - 15 Mar 2006
jason, the addition of a simple bit of debugging may help to clarify the problem. In the code above, on a new line before the line with "# rebuild message", add:
print STDERR $theText;
that should print the text of the mail message to STDERR. Given that your server is Windies, and I have never tested on a Windies server, I am supicious of the old \r\n problem.
--
CrawfordCurrie - 16 Mar 2006
I tested this for both the
mailnotify and
mailnotifier scripts:
mailnotify
- I opened
c:/twiki/lib/TWiki/Net.pm.
- I inserted
print STDERR $theText; at line 156 (this of course moved all subsequent lines - beginning with $theText = "$header\n\n$body"; # rebuild message - down one line).
- Saved the changes.
- From the Cygwin Bash Shell, typed
cd /twiki/bin.
- Pressed
Enter. The Cygwin Bash Shell changed to a /twiki/bin prompt.
- Typed
perl -T mailnotify.
- Pressed
Enter. The following output was generated:
TWiki mail notification
- to suppress all normal output: mailnotify -q
Checking TWiki.Bulletins
- Changed topics since 10 Mar 2006 - 19:57: DVRCameraSetup SQLStatementToAddL
eadingZerosToBarcodes BarcodePriceImporter TipsForLocatingInstallationDocumen
ts AutoTendering
- Sending mail notification to: jdvensel@mycompany.com
Date: Thu, 16 Mar 2006 14:37:08 GMT
%{
Templates for the parts of the mails sent out by mailnotify. The HTML
and PLAIN templates are in three parts; header, body (which is repeated
for each change), and footer. The result is embedded in MailNotifyBody
}%
-------------------------------
-------------------------------
-------------------------------
-------------------------------
-------------------------------
-------------------------------
-------------------------------
Use of uninitialized value in concatenation (.) or string at c:/twiki/lib/TWiki/
Net.pm line 157.
* ERROR: Can't send mail, missing 'From:'
- End TWiki.Bulletins
Checking TWiki.CustomerTraining
The above output is generated for each web with only the web name and list of changed topics differing; the message about the templates and the seven "dashed" lines that follow are repeated for each web check.
mailnotifier
- From the Cygwin Bash Shell
/twiki/bin prompt, typed perl mailnotifier.
- Pressed
Enter. The following output was generated:
Processing Bulletins
Last notification was at 10 Mar 2006 - 19:57
Found change to DVRCameraSetup
Found change to SQLStatementToAddLeadingZerosToBarcodes
Found change to BarcodePriceImporter
Found change to TipsForLocatingInstallationDocuments
Found change to AutoTendering
Date: Thu, 16 Mar 2006 15:03:11 GMT
%{
Templates for the parts of the mails sent out by mailnotify. The HTML
and PLAIN templates are in three parts; header, body (which is repeated
for each change), and footer. The result is embedded in MailNotifyBody
}%
-------------------------------
-------------------------------
-------------------------------
-------------------------------
-------------------------------
-------------------------------
-------------------------------
Use of uninitialized value in concatenation (.) or string at c:/twiki/lib/TWiki/
Net.pm line 157.
**** ERROR :Mail send failed: ERROR: Can't send mail, missing 'From:'
Date: Thu, 16 Mar 2006 15:03:12 GMT
%{
Templates for the parts of the mails sent out by mailnotify. The HTML
and PLAIN templates are in three parts; header, body (which is repeated
for each change), and footer. The result is embedded in MailNotifyBody
}%
-------------------------------
-------------------------------
-------------------------------
-------------------------------
-------------------------------
-------------------------------
-------------------------------
Use of uninitialized value in concatenation (.) or string at c:/twiki/lib/TWiki/
Net.pm line 157.
Retry 4 in 1 secs...**** ERROR :Mail send failed: ERROR: Can't send mail, missin
g 'From:'
Date: Thu, 16 Mar 2006 15:03:15 GMT
The above output is generated and then "retried" four times (Retry 4, Retry 3, Retry 2, and finally Retry 1). After the final retry, a message appears stating
Too many failures; aborting send. The script then proceeds to process each of the remaining webs in the same manner If there are any changes to topics in other webs, then the same messages, lines, and retry behavior shown above is generated for that web.
--
JasonVensel - 16 Mar 2006
UPDATE
I figured out what broke e-mail notification. The problem was (still is) with the
c:/twiki/templates/mailnotify.tmpl file. Specifically, the problem is with the version of that file that is included with the
MailerContrib zip file. As I mentioned before, after I first installed TWiki Cairo, e-mail notification worked just fine. At some point after I installed
MailerContrib, it stopped working. The reason it stopped working is because there is something in
Net.pm (I think this is the file that has the problem) that doesn't work with the version of
mailnotify.tmpl that is copied into the
templates directory when you install
MailerContrib. I restored the basic e-mail notification functionality in Cairo by replacing my existing
mailnotify.tmpl file with the one that is included in the TWiki Cairo distribution. I still don't have
MailerContrib (that is, per topic notification) working, but at least I have a better idea of what to look at.
I will attempt to get
MailerContrib working. When I do, I'll post my results here and mark this answered.
--
JasonVensel - 21 Mar 2006
Okay, that didn't take long.
MailerContrib is working. I just run the
/bin/mailnotifier script. I'm marking this answered.
--
JasonVensel - 21 Mar 2006
Glad it worked out!
AFter all,
Can't send mail, missing 'From:' was an indication that the
From was missing in the template topic. Please report that in the Dev topic in case this is not an file mixup issue during upgrade.
--
PeterThoeny - 21 Mar 2006
Here's a summary of what happened. I'm running Cairo and wanted to install
MailerContrib so I could do per topic notification. The only version of the
.zip file I could download and unzip from
Plugins.MailerContribAddOn was the most current one (used in Dakar). So, I unzipped it and then followed the instructions for installing it on Cairo. It didn't work so I created this post. You (Peter) eventually attached the correct version of the
.zip file (see this topic), which I was able to use. However, because it doesn't include a
mailnotify.tmpl file (why would it!), my system was still using the
mailnotify.tmpl file that comes with the Dakar version of the
.zip file!
By chance, I happened to look at the contents of the "Dakar"
MailerContrib.zip and noticed that it included a
mailnotify.tmpl file. I then compared the code of that file with the
mailnotify.tmpl file included in the Cairo installation distribution. When I noticed they were different, I copied in the installation version of that file, tested the
mailnotify script and it worked again. I then went out and made changes to multiple topics to see if the
mailnotifier script would only report changes for topics to which I had subscribed; it did.
The moral of the story is, if you run Cairo and want to install
MailerContrib verify the
mailnotify.tmpl file is the same one that comes with the Cairo installation distribution.
I will add this note to the Dev topic.
--
JasonVensel - 21 Mar 2006
Well done Jason! Note for the future: The installer scripts built with
BuildContrib (like the ones for
MailerContrib) all have an "uninstall" target. If you had
perl MailerContrib_installer uninstall
before unzipping the older zip, then you wouldn't have had the problem.
--
CrawfordCurrie - 22 Mar 2006
perl
MailerContrib_installer
###
MailerContrib Installer ###
This installer must be run from the root directory of your TWiki
installation.
* The script will not do anything without asking you for
confirmation first (unless you used -a).
* You can abort the script at any point and re-run it later
* If you answer 'no' to any questions you can always re-run
the script again later
##########################################################
Checking dependency on URI....
##########################################################
Checking dependency on URI::Escape....
Fetching the archive for TWiki::Contrib::Mailer.
An existing /var/www/html/twiki/MailerContrib.zip exists; would you like me to use it? [y/n] y
Got a local archive from /var/www/html/twiki/MailerContrib.zip
Archive::Zip is not installed; trying unzip on the command line
Archive: /var/www/html/twiki/MailerContrib.zip
- creating
- data/
- creating
- data/TWiki/ inflating: data/TWiki/MailerContrib.txt
- creating
- lib/
- creating
- lib/TWiki/
- creating
- lib/TWiki/Contrib/
- creating
- lib/TWiki/Contrib/MailerContrib/ inflating: lib/TWiki/Contrib/MailerContrib/WebNotify.pm inflating: lib/TWiki/Contrib/MailerContrib/Subscriber.pm inflating: lib/TWiki/Contrib/MailerContrib/Subscription.pm inflating: lib/TWiki/Contrib/MailerContrib/Change.pm inflating: lib/TWiki/Contrib/MailerContrib/UpData.pm inflating: lib/TWiki/Contrib/Mailer.pm inflating: MailerContrib_installer
- creating
- templates/ inflating: templates/mailnotify.tmpl inflating: templates/newsletter.tmpl
- creating
- tools/ inflating: tools/mailnotify
unzip failed: ·Ç·¨ seek ²Ù×÷
Failed to unpack archive /var/www/html/twiki/MailerContrib.zip
Archive unpacked
--
FanLei - 27 Oct 2006