summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorThorsten Behrens <tbehrens@novell.com>2011-02-23 01:49:56 +0100
committerThorsten Behrens <tbehrens@novell.com>2011-02-23 01:49:56 +0100
commit34daa0c20878ebd6054c703ef91e0dfcf9914ddf (patch)
treeb65d3149d4179d8d55f02125241c1f68b4b6beae /bin
parentd2a6b1e9a07831ba54a3c6f3604b451b2c5eb5dc (diff)
Enable tinbuild to also use SMTP auth
Previously, tinbuild was only able to use a local MTA - with this change, one can also e.g. use a googlemail account. Login creds and smtp crypt method gets passed via command line.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/tinbuild41
1 files changed, 35 insertions, 6 deletions
diff --git a/bin/tinbuild b/bin/tinbuild
index 2d29424cda82..044757c571f1 100755
--- a/bin/tinbuild
+++ b/bin/tinbuild
@@ -9,9 +9,14 @@ SEND_MAIL=0
NICE=
OWNER=
MACHINE=`uname`
-SMTP=
TINDERNAME=
+SMTPPORT=25
+SMTPCRYPT=none
+SMTPHOST=
+SMTPUSER=
+SMTPPW=
+
## subroutines
usage ()
{
@@ -23,6 +28,9 @@ usage ()
echo "-m <owner> mail errors to the committer, general errors to the <owner>"
echo "-n run with nice, can be combined with -i"
echo "-s <host> SMTP server"
+ echo "-c <type> SMTP crypt to use - either none, tls or ssl"
+ echo "-u <user> SMTP user name for auth login"
+ echo "-p <pass> SMTP password for auth login"
echo "-t <name> send tinderbox mails, identify self as <name>"
echo "-w <N> specify timeout in secs between subsequent pull requests"
}
@@ -43,6 +51,8 @@ sendMailMsg ()
perl -e "
use MIME::Lite;
use Net::SMTP;
+use Net::SMTP::SSL;
+use Net::SMTP::TLS;
my \$text;
while (<>) {
@@ -67,8 +77,24 @@ if ('$LOG' ne '' && -f '$LOG') {
) or die \"Error adding $LOG: \$!\n\";
}
-MIME::Lite->send('smtp', '$SMTP', Timeout=>60);
-\$msg->send;
+my \$smtp_class = '$SMTPCRYPT' eq 'none' ?
+ 'Net::SMTP' :
+ '$SMTPCRYPT' eq 'ssl' ? 'Net::SMTP::SSL' : 'Net::SMTP::TLS';
+my \$SMTP = \$smtp_class->new(
+ '$SMTPHOST',
+ Hello => 'documentfoundation.org',
+ Port => '$SMTPPORT',
+ User => '$SMTPUSER',
+ Password => '$SMTPPW' );
+die \"Cannot connect to SMTP server!\" unless defined \$SMTP;
+
+\$SMTP->mail('$OWNER');
+\$SMTP->to('$TO');
+\$SMTP->data();
+\$SMTP->datasend( \$msg->as_string() );
+\$SMTP->dataend();
+\$SMTP->quit();
+
print 'Sent a mail to \"$TO\" with subject \"$SUBJECT\".' . \"\n\";
"
}
@@ -183,14 +209,17 @@ tinderbox: END
}
## code
-while getopts hilm:ns:t:w: opt ; do
+while getopts hilm:ns:c:u:p:t:w: opt ; do
case "$opt" in
h) usage; exit ;;
i) NICE="$NICE ionice -c3" ;;
l) HTML_OUTPUT=1 ;;
m) SEND_MAIL=1 ; OWNER="$OPTARG" ;;
n) NICE="$NICE nice" ;;
- s) SMTP="$OPTARG" ;;
+ s) SMTPHOST="$OPTARG" ;;
+ c) SMTPCRYPT="$OPTARG" ;;
+ u) SMTPUSER="$OPTARG" ;;
+ p) SMTPPW="$OPTARG" ;;
t) TINDERNAME="$OPTARG" ;;
w) PAUSE_SECONDS="$OPTARG" ;;
?) usage; exit ;;
@@ -208,7 +237,7 @@ if test "$SEND_MAIL" -eq 1 ; then
echo "Owner not set."
exit 1
fi
- if test -z "$SMTP" ; then
+ if test -z "$SMTPHOST" ; then
echo "SMTP server not set."
exit 1
fi