Koozali.org: home of the SME Server
Other Languages => Italiano => Topic started by: bautzen on February 14, 2013, 12:37:37 PM
-
Ciao a tutti, siccome dopo varie ricerche sembra che solo io abbia questo problema 8-) (e te pareva!!!!), ho la necessità di scaricare tramite fetchmail degli account che tramite il mio ISP non è possibile accedere. Un esempio per tutti: da ADSL Telecom scaricare in POP3 mail di @libero.it o @inwind.it.
In una situazione del genere si installa degli accrocchi del tipo freepops o html2pop3, si imposta localhost:XXX e via il tutto funziona. In SME8 questo non sembra di facile risoluzione, per un neofita come sono io. Quindi mi sono un pò ingegnato ed ora funziona anche in SME8 ma solo con modifiche a mano del file /etc/fetchmail. Ovviamente ad ogni riavvio devo fare in modo di riapplicare la cosa. Vorrei rendere la cosa "integrata" pertanto ho proceduto come potevo arrivando fino ad un certo punto. Naturalmente spesso si parla del tipo "ti cambi il template come preferisci, lo metti in template-customs e via"... per il resto c'è GOOGLE. Ovviamente si danno per assodate antologie di PHP, DB, programmazione in tutte le declinazioni e simili. Quindi vedo chiedere un aiuto, un instradamento un qualsiasi suggerimento per fare questa modifica.
Ho installato JAVA e html2pop3 in SME8. Ho configurato html2pop3 ad ascoltare sulla porta TCP111 e partire come servizio all'avvio.
Il risultato da ottenere è che venga generato il file /etc/fetchmail dal pannello di sme in questa forma (da notare evidenziato in rosso l'aggiunta)
[root@vm-sme80 ~]# cat /etc/fetchmail
#!/bin/sh
#------------------------------------------------------------
# !!DO NOT MODIFY THIS FILE!!
#
# Manual changes will be lost when this file is regenerated.
#
# Please read the developer's guide, which is available
# at http://www.contribs.org/development/
#
# Copyright (C) 1999-2006 Mitel Networks Corporation
#------------------------------------------------------------
#
# Mail N1 Account for : mario.rossi
/usr/bin/fetchmail -P111 -d0 --verbose --syslog --sslproto '' --fetchmailrc - <<EOF
set postmaster "postmaster@mydomain.local"
set bouncemail
set properties ""
poll 127.0.0.1 with proto POP3 timeout 60 and options uidl no dns
user 'libero.it;ciccio.pasticcio\@inwind.it' smtpaddress mydomain.local with password 'xxxxxxx' is mario.rossi here keep
smtphost 127.0.0.200
EOF
#
# Mail N2 Account for : mario.rossi
/usr/bin/fetchmail -d0 --verbose --syslog --sslproto '' --fetchmailrc - <<EOF
set postmaster "postmaster@mydomain.local"
set bouncemail
set properties ""
poll pop.191.biz with proto POP3 timeout 60 and options uidl no dns
user 'RATO00001\@mydomain.191.it' smtpaddress mydomain.local with password 'xxxxxxx' is mario.rossi here keep
smtphost 127.0.0.200
EOF
#
# Mail N3 Account for : mario.rossi
/usr/bin/fetchmail -d0 --verbose --syslog --sslproto '' --fetchmailrc - <<EOF
set postmaster "postmaster@mydomain.local"
set bouncemail
set properties ""
poll pop.191.biz with proto POP3 timeout 60 and options uidl no dns
user 'ciccio.pasticcio\@mydomain.191.it' smtpaddress mydomain.local with password 'xxxxxxxx' is mario.rossi here keep
smtphost 127.0.0.200
EOF
#
#
Ho modificato il pannello di fetchmail in modo che dal menù a tendina "Protocollo da usare per leggere le mail" si possa scegliere quanto segue:
Pop -------------------------------------> "tipo di accesso mail": POP3
Imap -------------------------------------> "tipo di accesso mail": IMAP
SSL Pop (sperimentale) --------------------> "tipo di accesso mail": SPOP3
SSL Imap (sperimentale) --------------------> "tipo di accesso mail": SIMAP
Html2Pop3 - POP3 - (TCP 111) --------------> "tipo di accesso mail": H2P-POP3
Poi ho copiato il file /etc/e-smith/templates/etc/fetchmail/90fetchmail in /etc/e-smith/templates-custom/etc/fetchmail/90fetchmail
poi ho dato:
signal-event fetchmail-change;
Quindi in teoria (se ho compreso bene le guide) ora dovrei lavorare sul custom 90fetchmail
Secondo me la parte interessante a cui aggiungere l'argomento -P111 è nella parte evidenziata in BLU del file che riporto di seguito:
#
# End of Data conversion...
#
# New test : if FetchMails status is 'disabled', we don't want that
# this part of /etc/fetchmail be generated.
if ( $FM->prop('status') eq 'enabled' ) {
foreach my $account ( @users ) {
my $FetchN=0;
my $Debug = $account->prop( 'FM-DebugOption' ) || '' ;
my $spy = $account->prop( 'FM-SpyOption' ) || '' ;
my $keepopt = $account->prop( 'FM-KeepOption' ) || '' ;
my $transname = $account->prop( 'FM-TransName') || '' ;
my $usergt = $account->prop( 'FM-MailCopyTo') || '' ;
my $ghost = $account->prop( 'FM-Ghost') || 'NO' ;
my $name = $account->key ;
my $comment = $name ;
my $maxcpy = 0;
if ( $transname ne '' ) {
$transname =~ s/:/,/g ;
if ( $usergt eq '' ) { $usergt = $transname }
else { $usergt = $usergt . "," . $transname }
}
if($usergt ne '') {
$name = "fm_fm-" . $name ;
my $comment2 = '' ;
$comment2 = $comment . "," if ( $ghost ne 'YES' ) ;
$comment = "$comment delivered to : $name = $comment2 $usergt";
}
# PS 2005/08/02 -> 1.3.4-05
# tristate combination for the delivering host :
# 1) if 'FetchMails->fetchhost' is set then this is the delivery host
# This should normally never be the case...
# 2) If the (systemWide) 'SMTPSmartHost is set, then this is the delivey host for fetchmail
# 3) If none of these are set, then the delivery host is set to the domain name of the computer
# BTW, correcting a bug preventing previous version to use the SMTPSmartHost value...
# PS 2005/08/19 ->1.3.4-06
# considerable mistake ! I had an automagical configuration whistle, but not the good one.
# I Said that if a smartHost is set, fetchmail must send incoming mails to the SmartHost.
# But SmartHosts are for Outgoing mails !
# Now, fetchmail automagically send mail to a DelegateMailServer, if set-up.
my $DestSMTPServer = $FM->prop( 'fetchhost' ) || '' ;
# my $SMTPSmartHost = $db->get( 'SMTPSmartHost' );
# $smarthost = $SMTPSmartHost->value || '' if ( $smarthost eq '' ) ;
# DelegateMailServer not ever exists...
if ( my $DelegateMailServer = $db->get( 'DelegateMailServer' ) ) {
$DestSMTPServer = $DelegateMailServer->value || '' if ( $DestSMTPServer eq '' ) ;
}
if( $DestSMTPServer ne '')
{ $DestSMTPServer = "smtpaddress $DestSMTPServer" ; }
else
{ $DestSMTPServer = "smtpaddress $dom" ; }
my $keep='fetchall';
if($keepopt eq "YES") { $keep='keep'; }
elsif($keepopt eq "NEW") { $keep='no fetchall'; }
# Change by PS
my $FetchMailsAcc = '' ;
if ( defined $account->prop( 'FM-Accounts' ) ) {
$FetchMailsAcc = $account->prop( 'FM-Accounts' ) ;
}
my @FetchMailAccounts = split RS, $FetchMailsAcc ;
foreach my $FetchMailAcount ( @FetchMailAccounts ) {
$FetchN++ ;
my ( $mserv, $mtype, $mname, $mpass ) = split FS, $FetchMailAcount ;
if(not defined $mserv ) { $mserv='';}
if(not defined $mname ) { $mname='';}
if(not defined $mpass ) { $mpass='';}
if(not defined $mtype ) { $mtype='';}
if ($mserv ne '') {
my $ServOpt = ' and options uidl no dns';
if($mtype =~ /IMAP/ ) { $ServOpt = ' and options no dns'; }
# ver 1.3.5-01 : add a timeout option
# this option is equal to the value timeout in the
# FetchMails service configuration
$ServOpt = ' timeout ' . ( $FM->prop('timeout') || 60 ) . $ServOpt;
my $ssl = '';
if ( $mtype =~ s/^S// ) { $ssl = 'options ssl' }
my $mdbg='-d0 --silent --syslog';
if($Debug eq "YES") { $mdbg='-d0 --verbose --syslog'; }
my $staticvalue = "/usr/bin/fetchmail $mdbg --sslproto '' --fetchmailrc - <<EOF\n"
;
$staticvalue .= "set postmaster \"postmaster\@$dom\"\n" ;
$staticvalue .= "set bouncemail\nset properties \"\"\n" ;
# we need to convert the name and the password from HEX to text
$mname = pack( "H*", $mname ) ;
$mpass = pack( "H*", $mpass ) ;
# special case : the \ must be changed to \x5c !
$mname =~ s/[\\]/\\x5c/g ;
$mpass =~ s/[\\]/\\x5c/g ;
# escape some odd characters by \ (just add them between the [] if needed
$mname =~ s/([\^\$\@\'\"\`])/\\$1/g ;
$mpass =~ s/([\^\$\@\'\"\`])/\\$1/g ;
# special case : the ' must be quoted another way
$mname =~ s/[\']/\\x27/g ;
$mpass =~ s/[\']/\\x27/g ;
$OUT .= "#\n";
$OUT .= "# Mail N$FetchN Account for : $comment\n";
$OUT .= $staticvalue;
$OUT .= "poll $mserv with proto $mtype$ServOpt\n" ;
$OUT .= " user '$mname' $DestSMTPServer with password '" ;
$OUT .= "$mpass' is $name here $keep $ssl\n" ;
$OUT .= " smtphost 127.0.0.200\n" ;
$OUT .="EOF\n";
}
}
}
}
$OUT .="#\n#\n";
}
}
Io pensavo qualcosa del tipo aggiungere:
if($mtype =~ /H2P-POP3/ ) { $ServOpt = ' and options no dns'; }
............
my $staticvalue = "/usr/bin/fetchmail $mdbg -P111 '' --fetchmailrc - <<EOF\n"
;
Io ho fatto delle prove a dire il vero ma da completo neofita non ricevendo alcun errore e comunque il file /etc/fetchmail non veniva rigenerato con il -P111. Ma addirittura non so dirvi se SME8 stia effettivamente caricando il 90fetchmail dal template o dal template-custom .
Chiedo umilmente un aiuto
Grazie infinite
Pat
P.S.
spero di aver dato tutte le informazioni del caso. per il resto sono qui
[root@vm-sme80 ~]# rpm -qa | grep fetch
fetchmail-6.3.6-4.el5
smeserver-fetchmail-1.4-1.el5.sme
-
Ciao
purtroppo ho smesso di usare fethmail insieme a freepops o simili da tempo e non ho più accesso a quelle macchine, ma scavando nella miniera ho trovato questo frammento del file 90fetchmail in /etc/e-smith/templates-custom/etc/fetchmail del mio server
if ($mserv ne '') {
my $ServOpt = ' and options uidl no dns';
if($mtype =~ /IMAP/ ) { $ServOpt = ' and options no dns'; }
if ($mserv eq "$hostname.$dom") {
# $mport=' port 2000';
$mserv=' localhost port 2000 ';
}
sostanzialmente, se tu metti il tuo dominio locale come server, lui trasforma la cosa in localhost port 2000
se aggiusti come ti aggrada, dovrebbe funzionare..
noto inoltre che la parte di codice
if($keepopt eq "YES") { $keep='keep'; }
elsif($keepopt eq "NEW") { $keep='no fetchall'; }
dovrebbe dare la possibilità di decidere come effettuare il polling, se un fetchall, un keep o altro..
per vedere se sta usando il custom template o quello originale (ma non ho molti dubbi in merito) basta che verifichi se l'opzione con la porta viene scritta o meno :-)
HTH
-
Grazie ste del tuo prezioso intervento.
Non sono affatto un mago in fatto di codice ma:
$mserv=' localhost port 2000 '; (che nel mio caso sarà ovviamente 111) cosa mi dovrebbe generare nel file /etc/fetchmail?
nel senso io ho visto nel man di fetchmail che lui si aspetta un -Pxxxx (porta TCP specifica).
Vuoi dirmi che l'aggiunta viene "tradotta" in -P2000?
Appena posso provo la tua modifica (buona l'idea di intercettare il nome server traducendolo in altro)
Comunque la tua soluzione "vanifica" la strada da me percorsa di discriminare in base al protocollo (H2P-POP3) anzichè in base al nome del server.
Grazie molte stefano
aggiornerò appena provo
-
l'opzione -P è anche port xxxx IIRC
in any case, modifica quella parte come preferisci..
poi basta che metti il tuo dominio locale e sei a posto