View | Details | Raw Unified | Return to bug 5251
Collapse All | Expand All

(-)a/C4/Letters.pm (-1 / +3 lines)
Lines 624-630 sub SendQueuedMessages (;$) { Link Here
624
        # This is just begging for subclassing
624
        # This is just begging for subclassing
625
        next MESSAGE if ( lc($message->{'message_transport_type'}) eq 'rss' );
625
        next MESSAGE if ( lc($message->{'message_transport_type'}) eq 'rss' );
626
        if ( lc( $message->{'message_transport_type'} ) eq 'email' ) {
626
        if ( lc( $message->{'message_transport_type'} ) eq 'email' ) {
627
            _send_message_by_email( $message );
627
            _send_message_by_email( $message, $params->{'username'}, $params->{'password'}, $params->{'method'} );
628
        }
628
        }
629
        elsif ( lc( $message->{'message_transport_type'} ) eq 'sms' ) {
629
        elsif ( lc( $message->{'message_transport_type'} ) eq 'sms' ) {
630
            _send_message_by_sms( $message );
630
            _send_message_by_sms( $message );
Lines 789-794 ENDSQL Link Here
789
789
790
sub _send_message_by_email ($;$$$) {
790
sub _send_message_by_email ($;$$$) {
791
    my $message = shift or return;
791
    my $message = shift or return;
792
    my ($username, $password, $method) = @_;
792
793
793
    my $to_address = $message->{to_address};
794
    my $to_address = $message->{to_address};
794
    unless ($to_address) {
795
    unless ($to_address) {
Lines 824-829 sub _send_message_by_email ($;$$$) { Link Here
824
        Message => $content,
825
        Message => $content,
825
        'content-type' => $message->{'content_type'} || 'text/plain; charset="UTF-8"',
826
        'content-type' => $message->{'content_type'} || 'text/plain; charset="UTF-8"',
826
    );
827
    );
828
    $sendmail_params{'Auth'} = {user => $username, pass => $password, method => $method} if $username;
827
    if ( my $bcc = C4::Context->preference('OverdueNoticeBcc') ) {
829
    if ( my $bcc = C4::Context->preference('OverdueNoticeBcc') ) {
828
       $sendmail_params{ Bcc } = $bcc;
830
       $sendmail_params{ Bcc } = $bcc;
829
    }
831
    }
(-)a/misc/cronjobs/CONFIGURE.gmail (+65 lines)
Line 0 Link Here
1
=============================
2
Installation Guide for Configuring a Koha Server to Use a Gmail Account as its SMTP Server
3
=============================
4
5
Copyright (C) 2010 Foundations Bible College (http://www.foundations.edu)
6
7
Author: Chris Nighswonger (cnighswonger AT foundations DOT edu
8
9
Feedback/bug reports: Koha Developer's List:
10
http://lists.koha.org/mailman/listinfo/koha-devel
11
12
This document last modified: 13 February 2010
13
14
Configuration Instructions
15
=============================
16
17
To use your gmail account as an SMTP server you will need to execute the following from a shell prompt.
18
19
(These steps are taken from http://jonspriggs.posterous.com/use-gmails-smtp-gateway-using-the-command-lin)
20
21
sudo apt-get install openssl xinetd
22
23
sudo tee /usr/bin/gmail-smtp <<EOF >/dev/null
24
#!/bin/sh
25
# Thanks to http://ubuntuforums.org/showthread.php?t=918335 for this install guide
26
/usr/bin/openssl s_client -connect smtp.gmail.com:465 -quiet 2>/dev/null
27
EOF
28
sudo chmod +x /usr/bin/gmail-smtp
29
30
sudo tee /etc/xinetd.d/gmail-smtp <<EOF >/dev/null
31
# default: on
32
# description: Gmail SMTP wrapper for clients without SSL support
33
# Thanks to http://ubuntuforums.org/showthread.php?t=918335 for this install guide
34
service gmail-smtp
35
{
36
    disable         = no
37
    bind            = localhost
38
    port            = 10025
39
    socket_type     = stream
40
    protocol        = tcp
41
    wait            = no
42
    user            = root
43
    server          = /usr/bin/gmail-smtp
44
    type            = unlisted
45
}
46
EOF
47
sudo /etc/init.d/xinetd reload
48
49
Edit Mail/Sendmail.pm and set the port to 10025. (Note: This file will be located where ever your Perl libraries are.)
50
51
Script Setup Instructions
52
=============================
53
54
After successfully executing the above steps, you will need to run the process_message_queue.pl script with the
55
following syntax:
56
57
perl process_message_queue.pl -u librarian@foo.tld -p supersecret -m LOGIN
58
59
This, of course, assumes that you have all other scripts in place and functional to generate notices.
60
61
Misc Helpful Notes
62
=============================
63
64
NOTE: In order to debug problems, you can set the debug level in Mail/Sendmail.pm to 11 which will give plenty of
65
commentary to STDOUT.
(-)a/misc/cronjobs/process_message_queue.pl (-7 / +16 lines)
Lines 28-39 BEGIN { Link Here
28
use C4::Letters;
28
use C4::Letters;
29
use Getopt::Long;
29
use Getopt::Long;
30
30
31
my $username = undef;
32
my $password = undef;
33
my $method = 'LOGIN';
31
my $help = 0;
34
my $help = 0;
32
my $verbose = 0;
35
my $verbose = 0;
33
36
34
GetOptions( 'h'    => \$help,
37
GetOptions(
35
            'v'    => \$verbose,
38
    'u|username:s'      => \$username,
36
       );
39
    'p|password:s'      => \$password,
40
    'm|method:s'        => \$method,
41
    'h|help|?'          => \$help,
42
    'v|verbose'         => \$verbose,
43
);
37
my $usage = << 'ENDUSAGE';
44
my $usage = << 'ENDUSAGE';
38
45
39
This script processes the message queue in the message_queue database
46
This script processes the message queue in the message_queue database
Lines 43-54 you run this regularly from cron, especially if you are using the Link Here
43
advance_notices.pl script.
50
advance_notices.pl script.
44
51
45
This script has the following parameters :
52
This script has the following parameters :
46
    -h help: this message
53
    -u --username: username of mail account
47
    -v verbose
54
    -p --password: password of mail account
55
    -m --method: authentication method required by SMTP server (See perldoc Sendmail.pm for supported authentication types.)
56
    -h --help: this message
57
    -v --verbose: provides verbose output to STDOUT
48
58
49
ENDUSAGE
59
ENDUSAGE
50
60
51
die $usage if $help;
61
die $usage if $help;
52
62
53
C4::Letters::SendQueuedMessages( { verbose => $verbose } );
63
C4::Letters::SendQueuedMessages( { verbose => $verbose, username => $username, password => $password, method => $method } );
54
64
55
- 

Return to bug 5251