text
stringlengths
0
357
&& param->send_server ==NULL
&& param->send_port ==0
&& param->send_user ==NULL
/*&&param->send_pw ==NULL -- the password cannot be auto-configured and is no criterion for autoconfig or not */
&& (param->server_flags & (~DC_LP_AUTH_OAUTH2))==0 /* flags but OAuth2 avoid autoconfig */
)
{
int keep_flags = param->server_flags & DC_LP_AUTH_OAUTH2;
/* A. Search configurations from the domain used in the email-address, prefer encrypted */
if (param_autoconfig==NULL) {
char* url = dc_mprintf("https://autoconfig.%s/mail/config-v1.1.xml?emailaddress=%s", param_domain, param_addr_urlencoded);
param_autoconfig = moz_autoconfigure(context, url, param);
free(url);
PROGRESS(300)
}
if (param_autoconfig==NULL) {
char* url = dc_mprintf("https://%s/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=%s", param_domain, param_addr_urlencoded); // the doc does not mention `emailaddress=`, however, Thunderbird adds it, see https://releases.mozilla.org/pub/thunderbird/ , which makes some sense
param_autoconfig = moz_autoconfigure(context, url, param);
free(url);
PROGRESS(310)
}
for (int i = 0; i <= 1; i++) {
if (param_autoconfig==NULL) {
char* url = dc_mprintf("https://%s%s/autodiscover/autodiscover.xml", i==0?"":"autodiscover.", param_domain); /* Outlook uses always SSL but different domains */
param_autoconfig = outlk_autodiscover(context, url, param);
free(url);
PROGRESS(320+i*10)
}
}
if (param_autoconfig==NULL) {
char* url = dc_mprintf("http://autoconfig.%s/mail/config-v1.1.xml?emailaddress=%s", param_domain, param_addr_urlencoded);
param_autoconfig = moz_autoconfigure(context, url, param);
free(url);
PROGRESS(340)
}
if (param_autoconfig==NULL) {
char* url = dc_mprintf("http://%s/.well-known/autoconfig/mail/config-v1.1.xml", param_domain); // do not transfer the email-address unencrypted
param_autoconfig = moz_autoconfigure(context, url, param);
free(url);
PROGRESS(350)
}
/* B. If we have no configuration yet, search configuration in Thunderbird's centeral database */
if (param_autoconfig==NULL)
{
char* url = dc_mprintf("https://autoconfig.thunderbird.net/v1.1/%s", param_domain); /* always SSL for Thunderbird's database */
param_autoconfig = moz_autoconfigure(context, url, param);
free(url);
PROGRESS(500)
}
/* C. Do we have any result? */
if (param_autoconfig)
{
{ char* r = dc_loginparam_get_readable(param_autoconfig); dc_log_info(context, 0, "Got autoconfig: %s", r); free(r); }
if (param_autoconfig->mail_user) {
free(param->mail_user);
param->mail_user= dc_strdup_keep_null(param_autoconfig->mail_user);
}
param->mail_server = dc_strdup_keep_null(param_autoconfig->mail_server); /* all other values are always NULL when entering autoconfig */
param->mail_port = param_autoconfig->mail_port;
param->send_server = dc_strdup_keep_null(param_autoconfig->send_server);
param->send_port = param_autoconfig->send_port;
param->send_user = dc_strdup_keep_null(param_autoconfig->send_user);
param->server_flags = param_autoconfig->server_flags;
/* althoug param_autoconfig's data are no longer needed from, it is important to keep the object as
we may enter "deep guessing" if we could not read a configuration */
}
param->server_flags |= keep_flags;
}
/* 2. Fill missing fields with defaults
**************************************************************************/
#define TYPICAL_IMAP_SSL_PORT 993 /* our default */
#define TYPICAL_IMAP_STARTTLS_PORT 143 /* not used very often but eg. by posteo.de, default for PLAIN */
#define TYPICAL_SMTP_SSL_PORT 465 /* our default */
#define TYPICAL_SMTP_STARTTLS_PORT 587 /* also used very often, SSL:STARTTLS is maybe 50:50 */
#define TYPICAL_SMTP_PLAIN_PORT 25
if (param->mail_server==NULL) {
param->mail_server = dc_mprintf("imap.%s", param_domain);
}
if (param->mail_port==0) {
param->mail_port = (param->server_flags&(DC_LP_IMAP_SOCKET_STARTTLS|DC_LP_IMAP_SOCKET_PLAIN))? TYPICAL_IMAP_STARTTLS_PORT : TYPICAL_IMAP_SSL_PORT;
}
if (param->mail_user==NULL) {
param->mail_user = dc_strdup(param->addr);