This has only been tried on macOS 11. And even then I haven't run these instructions end-to-end. This is pieced together from trial & error.
This could be scripted but it's late.
-
Go to devtools of https://beta.protonmail.com/settings/u/0/identity
-
Find the https://beta.protonmail.com/api/addresses request in the Network panel
-
Copy the response json
-
In the devtools console set:
var c = { ...copied json... };
- Clean out super secret stuff and keep only
{ [email1]: "Display Name 1", ... }
:
var noms = c.Addresses.reduce((acc, o) => {
acc[o.Email] = o.DisplayName;
return acc;
}, {});
- With ProtonMail Bridge, get the local credentials with 'info' and save it to a txt file:
$ "/Applications/ProtonMail Bridge.app/Contents/MacOS/ProtonMail Bridge" --cli
>>> info
...
Configuration for [email protected]
IMAP Settings
Address: 127.0.0.1
IMAP port: 1143
Username: [email protected]
Password: abc123
Security: STARTTLS
SMTP Settings
Address: 127.0.0.1
IMAP port: 1025
Username: [email protected]
Password: abc123
Security: SSL
...
>>> exit
$
- Somehow get this txt file to look like this json:
{
"smtp": {
"username": "[email protected]",
"security": "SSL",
"port": "1025",
"password": "abc123",
"address": "127.0.0.1"
},
"imap": {
"username": "[email protected]",
"security": "STARTTLS",
"port": "1143",
"password": "abc123",
"address": "127.0.0.1"
}
}
- Add display names with this:
creds.forEach((el, i, arr) => {
arr[i].displayName = noms[el.imap.username];
});
Turn this into the XML config format with this:
var cfg = `
<?xml version="1.0" encoding="UTF-8"?>\n<clientConfig version="1.1">` +
creds.map(el => `
<emailProvider id="${el.imap.username}">
<domain>${el.imap.username.split('@')[1]}</domain>
<displayName>${el.displayName}</displayName>
<displayShortName>${(el.displayName.match(/\b[A-Z]+/g) || []).join('')}</displayShortName>
<incomingServer type="imap">
<hostname>${el.imap.address}</hostname>
<port>${el.imap.port}</port>
<socketType>${el.imap.security}</socketType>
<authentication>password-cleartext</authentication>
<password>${el.imap.password}</password>
<username>${el.imap.username}</username>
</incomingServer>
<outgoingServer type="smtp">
<hostname>${el.smtp.address}</hostname>
<port>${el.smtp.port}</port>
<socketType>${el.smtp.security}</socketType>
<authentication>password-cleartext</authentication>
<password>${el.smtp.password}</password>
<username>${el.smtp.username}</username>
</outgoingServer>
<emailProvider>
`).join('\n') + `
</clientConfig>`;
- X
var credsMap = {};
creds.forEach(o => {
var d = o.imap.username.split('@')[1] + '.xml';
if(!credsMap[d]) credsMap[d] = [];
credsMap[d].push(o);
});
var credsMapXml = Object.fromEntries(Object.entries(credsMap).map(([fn, vArr]) => [fn, `
<?xml version="1.0" encoding="UTF-8"?>
<clientConfig version="1.1">` + vArr.map(el => `
<emailProvider id="${el.imap.username}">
<domain>${el.imap.username.split('@')[1]}</domain>
<displayName>${el.displayName}</displayName>
<displayShortName>${(el.displayName.match(/\b[A-Z]+/g) || []).join('')}</displayShortName>
<incomingServer type="imap">
<hostname>${el.imap.address}</hostname>
<port>${el.imap.port}</port>
<socketType>${el.imap.security}</socketType>
<authentication>password-cleartext</authentication>
<password>${el.imap.password}</password>
<username>${el.imap.username}</username>
</incomingServer>
<outgoingServer type="smtp">
<hostname>${el.smtp.address}</hostname>
<port>${el.smtp.port}</port>
<socketType>${el.smtp.security}</socketType>
<authentication>password-cleartext</authentication>
<password>${el.smtp.password}</password>
<username>${el.smtp.username}</username>
</outgoingServer>
<emailProvider>
`).join('\n') + `
</clientConfig>`
]));
writeFile = require('fs').writeFile;
for(const [fn, str] of Object.entries(credsMapXml)) {
writeFile(fn, str, 'utf8', err => {
if(err) throw err;
});
}
- Try to figure out what to do with the file by reading these:
- https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Autoconfiguration
- "installdir/isp/emailaddressdomain.xml" https://wiki.mozilla.org/Thunderbird:Autoconfiguration