Commit d31c1603 authored by Chris Nighswonger's avatar Chris Nighswonger Committed by Chris Cormack

Bug 5251 : Enhancement: [3.2] (Resubmission) Adding code to support using gmail as an SMTP server

This patch adds support for using a gmail account as an SMTP server.
It includes a basic HOWTO.
Signed-off-by: default avatarMagnus Enger <magnus@enger.priv.no>
Signed-off-by: default avatarChris Cormack <chrisc@catalyst.net.nz>
parent d8b362e0
......@@ -624,7 +624,7 @@ sub SendQueuedMessages (;$) {
# This is just begging for subclassing
next MESSAGE if ( lc($message->{'message_transport_type'}) eq 'rss' );
if ( lc( $message->{'message_transport_type'} ) eq 'email' ) {
_send_message_by_email( $message );
_send_message_by_email( $message, $params->{'username'}, $params->{'password'}, $params->{'method'} );
}
elsif ( lc( $message->{'message_transport_type'} ) eq 'sms' ) {
_send_message_by_sms( $message );
......@@ -789,6 +789,7 @@ ENDSQL
sub _send_message_by_email ($;$$$) {
my $message = shift or return;
my ($username, $password, $method) = @_;
my $to_address = $message->{to_address};
unless ($to_address) {
......@@ -824,6 +825,7 @@ sub _send_message_by_email ($;$$$) {
Message => $content,
'content-type' => $message->{'content_type'} || 'text/plain; charset="UTF-8"',
);
$sendmail_params{'Auth'} = {user => $username, pass => $password, method => $method} if $username;
if ( my $bcc = C4::Context->preference('OverdueNoticeBcc') ) {
$sendmail_params{ Bcc } = $bcc;
}
......
=============================
Installation Guide for Configuring a Koha Server to Use a Gmail Account as its SMTP Server
=============================
Copyright (C) 2010 Foundations Bible College (http://www.foundations.edu)
Author: Chris Nighswonger (cnighswonger AT foundations DOT edu
Feedback/bug reports: Koha Developer's List:
http://lists.koha.org/mailman/listinfo/koha-devel
This document last modified: 13 February 2010
Configuration Instructions
=============================
To use your gmail account as an SMTP server you will need to execute the following from a shell prompt.
(These steps are taken from http://jonspriggs.posterous.com/use-gmails-smtp-gateway-using-the-command-lin)
sudo apt-get install openssl xinetd
sudo tee /usr/bin/gmail-smtp <<EOF >/dev/null
#!/bin/sh
# Thanks to http://ubuntuforums.org/showthread.php?t=918335 for this install guide
/usr/bin/openssl s_client -connect smtp.gmail.com:465 -quiet 2>/dev/null
EOF
sudo chmod +x /usr/bin/gmail-smtp
sudo tee /etc/xinetd.d/gmail-smtp <<EOF >/dev/null
# default: on
# description: Gmail SMTP wrapper for clients without SSL support
# Thanks to http://ubuntuforums.org/showthread.php?t=918335 for this install guide
service gmail-smtp
{
disable = no
bind = localhost
port = 10025
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/gmail-smtp
type = unlisted
}
EOF
sudo /etc/init.d/xinetd reload
Edit Mail/Sendmail.pm and set the port to 10025. (Note: This file will be located where ever your Perl libraries are.)
Script Setup Instructions
=============================
After successfully executing the above steps, you will need to run the process_message_queue.pl script with the
following syntax:
perl process_message_queue.pl -u librarian@foo.tld -p supersecret -m LOGIN
This, of course, assumes that you have all other scripts in place and functional to generate notices.
Misc Helpful Notes
=============================
NOTE: In order to debug problems, you can set the debug level in Mail/Sendmail.pm to 11 which will give plenty of
commentary to STDOUT.
......@@ -28,12 +28,19 @@ BEGIN {
use C4::Letters;
use Getopt::Long;
my $username = undef;
my $password = undef;
my $method = 'LOGIN';
my $help = 0;
my $verbose = 0;
GetOptions( 'h' => \$help,
'v' => \$verbose,
);
GetOptions(
'u|username:s' => \$username,
'p|password:s' => \$password,
'm|method:s' => \$method,
'h|help|?' => \$help,
'v|verbose' => \$verbose,
);
my $usage = << 'ENDUSAGE';
This script processes the message queue in the message_queue database
......@@ -43,12 +50,15 @@ you run this regularly from cron, especially if you are using the
advance_notices.pl script.
This script has the following parameters :
-h help: this message
-v verbose
-u --username: username of mail account
-p --password: password of mail account
-m --method: authentication method required by SMTP server (See perldoc Sendmail.pm for supported authentication types.)
-h --help: this message
-v --verbose: provides verbose output to STDOUT
ENDUSAGE
die $usage if $help;
C4::Letters::SendQueuedMessages( { verbose => $verbose } );
C4::Letters::SendQueuedMessages( { verbose => $verbose, username => $username, password => $password, method => $method } );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment