Commit fc2b8240 authored by pierre_f's avatar pierre_f
Browse files

mailclient autoconfig

parent e3579512
......@@ -530,6 +530,14 @@ lang/.svnignore -text
lang/README -text
lang/en_US.po -text
lang/nl_NL.po -text
mailautoconfig/apache_mail-autoconfig.conf -text
mailautoconfig/cron_bash -text
mailautoconfig/var/www/mail_autoconfig/.htaccess -text
mailautoconfig/var/www/mail_autoconfig/index.html -text
mailautoconfig/var/www/mail_autoconfig/outlook.php -text
mailautoconfig/var/www/mail_autoconfig/outlook.php__DYN -text
mailautoconfig/var/www/mail_autoconfig/thunderbird.php -text
mailautoconfig/var/www/mail_autoconfig/thunderbird.php__DYN -text
man/alternc-admintools.8 -text
man/alternc-admintools.fr.8 -text
man/alternc.install.pod -text
......
# ce vhosts est fonctionnel sur le serveur ici dans l'exemple, hostname : petdev.octopuce.fr
# la plus belle façon de faire, serait que le vhosts d'apache par defaut gere les alias
# exemple de log pour icedov (comme thunderboird) :
# /var/log/apache2/mailconfig.log:10.1.0.254 - - [22/Jul/2013:12:54:29 +0200] begin:1374490469 end:1374490469 "GET /mail/config-v1.1.xml?emailaddress=test%40petdev2.octopuce.fr HTTP/1.1" 200 sent 602 328 0 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130704 Icedove/17.0.7" autoconfig.petdev2.octopuce.fr
# exemple pour outlook
# /var/log/apache2/mailconfig.log:10.1.0.254 - - [22/Jul/2013:14:23:23 +0200] begin:1374495803 end:1374495803 "GET /autodiscover/autodiscover.xml HTTP/1.1" 200 sent 1044 794 0 "-" "Microsoft Office/14.0 (Windows NT 5.1; Microsoft Outlook 14.0.6126; Pro)" autodiscover.petdev2.octopuce.fr
# configuration du repertoire :
<Directory "/var/www/mail_autoconfig">
php_admin_value open_basedir "/var/www/mail_autoconfig/:/usr/share/php/:/var/alternc/tmp:/tmp"
Options +MultiViews -FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride AuthConfig FileInfo Limit Options Indexes
Order allow,deny
allow from all
</Directory>
# 443/SSL pour les clients outlook
# normalement autidiscover serait suffisant, car autoconfig est utilise par thunderbird
NameVirtualHost autodiscover.petdev.octopuce.fr:443
<VirtualHost autodiscover.petdev.octopuce.fr:443>
ServerName autodiscover.localhost
ServerAlias autoconfig.*
ServerAlias autodiscover.*
SSLEngine on
SSLCertificateFile /etc/ssl/private/localhost.all
SSLCaCertificatePath /etc/ssl/certs
LogFormat "%h %l %u %t %{begin:%s}t %{end:%s}t \"%r\" %>s sent %O %b %T \"%{Referer}i\" \"%{User-Agent}i\" %{Host}i" mailconfig
CustomLog ${APACHE_LOG_DIR}/mailconfig.log mailconfig
DocumentRoot /var/www/mail_autoconfig/
</VirtualHost>
<VirtualHost *:80>
ServerName autodiscover.localhost
ServerAlias autoconfig.*
ServerAlias autodiscover.*
LogFormat "%h %l %u %t %{begin:%s}t %{end:%s}t \"%r\" %>s sent %O %b %T \"%{Referer}i\" \"%{User-Agent}i\" %{Host}i" mailconfig
CustomLog ${APACHE_LOG_DIR}/mailconfig.log mailconfig
DocumentRoot /var/www/mail_autoconfig/
</VirtualHost>
#!/bin/bash
# cron pouvant servir au cas ou la foinctionnalite n est pas intergre a alternc
PUBLIC_IP="`awk -F'"' '/^PUBLIC_IP/ {print $2}' /etc/alternc/local.sh`"
if [ -d "/var/alternc/bind/zones" ]
then
BINDDIR="/var/alternc/bind/zones"
fi
if [ -d "/var/lib/alternc/bind/zones" ]
then
BINDDIR="/var/lib/alternc/bind/zones"
fi
BINDRELOAD=0
while read domaine gesmx gesdns
do
# for debug
#echo $domaine $gesmx $gesdns
if [ $gesdns -eq 0 ]
then
sed -i '/^autodiscover/d' $BINDDIR/$domaine
sed -i '/^autoconfig/d' $BINDDIR/$domaine
else
if [ $gesmx -eq 0 ]
then
sed -i '/^autodiscover/d' $BINDDIR/$domaine
sed -i '/^autoconfig/d' $BINDDIR/$domaine
else
ZNSERIAL="`awk '/; serial/ {print $1}' $BINDDIR/$domaine`"
NEWZNSERIAL=$((ZNSERIAL+1))
# for debug
#echo $ZNSERIAL $NEWZNSERIAL $BINDDIR
if [ `grep "^autodiscover " $BINDDIR/$domaine | wc -l` -ge 1 ]
then
echo -e "autodiscover IN A $PUBLIC_IP" >> /dev/null
else
echo -e "autodiscover IN A $PUBLIC_IP" >> $BINDDIR/$domaine
sed -i '/; serial[ \t]*$/ s/'$ZNSERIAL'/'$NEWZNSERIAL'/' $BINDDIR/$domaine
fi
if [ `grep "^autoconfig " $BINDDIR/$domaine | wc -l` -ge 1 ]
then
echo -e "autoconfig IN A $PUBLIC_IP" >> /dev/null
else
echo -e "autoconfig IN A $PUBLIC_IP" >> $BINDDIR/$domaine
sed -i '/; serial[ \t]*$/ s/'$ZNSERIAL'/'$NEWZNSERIAL'/' $BINDDIR/$domaine
fi
fi
fi
if [ `awk '/; serial/ {print $1}' $BINDDIR/$domaine` -gt $ZNSERIAL ]
then
BINDRELOAD=$((BINDRELOAD+1))
fi
done < <(mysql --defaults-file=/etc/alternc/my.cnf -e "select domaine,gesmx,gesdns from domaines;" alternc | grep -v \| | tail --lines=+2)
if [ $BINDRELOAD -ne 0 ]
then
/usr/sbin/rndc reload
fi
RewriteEngine On
RewriteRule ^mail/mailautoconfig.xml$ /thunderbird.php [L]
RewriteRule ^mail/config-v1.1.xml$ /thunderbird.php [L]
RewriteRule ^autodiscover/autodiscover.xml$ /outlook.php [L]
RewriteRule ^Autodiscover/Autodiscover.xml$ /outlook.php [L]
RewriteRule ^Autodiscover.xml$ outlook.php [L]
RewriteRule ^autodiscover.xml$ outlook.php [L]
<?php
// Created by Alesandro Slepcevic - alesandro@plus.hr
//header(':', true, 405);
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ){
$postText = file_get_contents('php://input');
$string = $postText;
$matches = array();
$pattern = '/[A-Za-z0-9_-]+@[A-Za-z0-9_-]+.([A-Za-z0-9_-][A-Za-z0-9_]+)/';
preg_match($pattern, $string, $matches);
$emailDomain = explode('@', $matches[0]);
$f=fopen("/tmp/autodiscover.log","ab");
fputs($f,"Posted: \n".$string."\n");
fclose($f);
}
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?> \n";
?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
<Account>
<AccountType>email</AccountType>
<Action>settings</Action>
<Protocol>
<Type>IMAP</Type>
<Server><?php echo exec('hostname -f');?></Server>
<Port>993</Port>
<LoginName><?php echo $matches[0];?></LoginName>
<DomainName><?php echo $emailDomain[1];?></DomainName>
<SPA>off</SPA>
<SSL>on</SSL>
<AuthRequired>on</AuthRequired>
</Protocol>
<Protocol>
<Type>SMTP</Type>
<Server><?php echo exec('hostname -f');?></Server>
<Port>587</Port>
<SPA>off</SPA>
<SSL>on</SSL>
<AuthRequired>on</AuthRequired>
<UsePOPAuth>on</UsePOPAuth>
<SMTPLast>off</SMTPLast>
</Protocol>
</Account>
</Response>
</Autodiscover>
<?php
// Created by Alesandro Slepcevic - alesandro@plus.hr
header(':', true, 405);
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ){
$postText = file_get_contents('php://input');
$string = $postText;
$matches = array();
$pattern = '/[A-Za-z0-9_-]+@[A-Za-z0-9_-]+.([A-Za-z0-9_-][A-Za-z0-9_]+)/';
preg_match($pattern, $string, $matches);
$emailDomain = explode('@', $matches[0]);
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?> \n";
}
?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
<Account>
<AccountType>email</AccountType>
<Action>settings</Action>
<Protocol>
<Type>IMAP</Type>
<Server>mail.<?php echo $emailDomain[1];?></Server>
<Port>993</Port>
<LoginName><?php echo $matches[0];?></LoginName>
<DomainName><?php echo $emailDomain[1];?></DomainName>
<SPA>off</SPA>
<SSL>on</SSL>
<AuthRequired>on</AuthRequired>
</Protocol>
<Protocol>
<Type>SMTP</Type>
<Server>mail.<?php echo $emailDomain[1];?></Server>
<Port>465</Port>
<SPA>off</SPA>
<SSL>on</SSL>
<AuthRequired>on</AuthRequired>
<UsePOPAuth>on</UsePOPAuth>
<SMTPLast>off</SMTPLast>
</Protocol>
</Account>
</Response>
</Autodiscover>
<?php
header ("Content-Type:text/xml");
$emailDomain = explode('@', rawurldecode($_GET['emailaddress']));
?>
<clientConfig version="1.1">
<emailProvider id="octopuce.fr">
<domain><?php echo $emailDomain;?></domain>
<displayName>Octopuce SARL</displayName>
<displayShortName>Octopuce</displayShortName>
<incomingServer type="imap">
<hostname><?php echo exec('hostname -f');?></hostname>
<port>993</port>
<socketType>SSL</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</incomingServer>
<incomingServer type="pop3">
<hostname><?php echo exec('hostname -f');?></hostname>
<port>995</port>
<socketType>SSL</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</incomingServer>
<outgoingServer type="smtp">
<hostname><?php echo exec('hostname -f');?></hostname>
<port>587</port>
<socketType>STARTTLS</socketType>
<username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication>
</outgoingServer>
<outgoingServer type="smtp">
<hostname><?php echo exec('hostname -f');?></hostname>
<port>465</port>
<socketType>SSL</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</outgoingServer>
</emailProvider>
</clientConfig>
<?php
header ("Content-Type:text/xml");
$emailDomain = explode('@', rawurldecode($_GET['emailaddress']));
?>
<clientConfig version="1.1">
<emailProvider id="octopuce.fr">
<domain>octopuce.fr</domain>
<domain>octopuce.biz</domain>
<displayName>Octopuce Mail</displayName>
<displayShortName>Octopuce</displayShortName>
<incomingServer type="imap">
<hostname>mail.%EMAILDOMAIN%</hostname>
<port>993</port>
<socketType>SSL</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</incomingServer>
<incomingServer type="pop3">
<hostname>mail.%EMAILDOMAIN%</hostname>
<port>995</port>
<socketType>SSL</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</incomingServer>
<outgoingServer type="smtp">
<hostname>mail.%EMAILDOMAIN%</hostname>
<port>587</port>
<socketType>STARTTLS</socketType>
<username>%EMAILADDRESS%</username>
<authentication>password-cleartext</authentication>
</outgoingServer>
<outgoingServer type="smtp">
<hostname>mail.%EMAILDOMAIN%</hostname>
<port>465</port>
<socketType>SSL</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</outgoingServer>
</emailProvider>
</clientConfig>
Supports Markdown
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