https://wiki.archlinux.org/api.php?action=feedcontributions&user=Petrus&feedformat=atomArchWiki - User contributions [en]2024-03-19T10:53:33ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Isync&diff=735471Isync2022-06-28T20:47:57Z<p>Petrus: Added mailctl OAuth2 utility + minor editing.</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Mail retrieval agents]]<br />
[[ja:Isync]]<br />
[http://isync.sourceforge.net/ isync] is a command line application to synchronize mailboxes; it supports Maildir and IMAP4 mailboxes. New messages, message deletions and flag changes can be propagated both ways.<br />
<br />
Synchronization is based on unique message identifiers (UIDs), so no identification conflicts can occur (as opposed to some other mail synchronizers).<br />
Synchronization state is kept in one local text file per mailbox pair; multiple replicas of a mailbox can be maintained.<br />
{{note|isync is the name of the project, mbsync is the name of the executable}}<br />
<br />
== Installing ==<br />
<br />
[[Install]] the {{Pkg|isync}} package.<br />
<br />
== Configuring ==<br />
<br />
{{Note| Google appears to block isync from downloading emails by default. If you have 2-step authentication enabled, you need to [https://myaccount.google.com/apppasswords set up an app password] and use that with isync, otherwise you need to go to [https://myaccount.google.com/security Google's Security Page] and toggle "Allow less secure apps" to "on".}}<br />
<br />
{{Note|'''Subfolders''' setting in MaildirStore now seems to be required to be set: [http://isync.sourceforge.net/mbsync.html iSync Config SubFolders] '''SubFolders Legacy''' worked as previous unset - Oct 2017}}<br />
<br />
First create and customize the main configuration file using this example {{ic|~/.mbsyncrc}}:<br />
{{hc|~/.mbsyncrc|2=<br />
<nowiki><br />
IMAPAccount gmail<br />
# Address to connect to<br />
Host imap.gmail.com<br />
User username@gmail.com<br />
Pass ***************<br />
# To store the password in an encrypted file use PassCmd instead of Pass<br />
# PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.mailpass.gpg"<br />
#<br />
# Use SSL<br />
SSLType IMAPS<br />
# The following line should work. If you get certificate errors, uncomment the two following lines and read the "Troubleshooting" section.<br />
CertificateFile /etc/ssl/certs/ca-certificates.crt<br />
#CertificateFile ~/.cert/imap.gmail.com.pem<br />
#CertificateFile ~/.cert/Equifax_Secure_CA.pem<br />
<br />
IMAPStore gmail-remote<br />
Account gmail<br />
<br />
MaildirStore gmail-local<br />
SubFolders Verbatim<br />
# The trailing "/" is important<br />
Path ~/.mail/gmail/<br />
Inbox ~/.mail/gmail/Inbox<br />
<br />
Channel gmail<br />
Far :gmail-remote:<br />
Near :gmail-local:<br />
# Exclude everything under the internal [Gmail] folder, except the interesting folders<br />
Patterns * ![Gmail]* "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail"<br />
# Or include everything<br />
#Patterns *<br />
# Automatically create missing mailboxes, both locally and on the server<br />
Create Both<br />
# Sync the movement of messages between folders and deletions, add after making sure the sync works<br />
Expunge Both<br />
# Save the synchronization state files in the relevant directory<br />
SyncState *<br />
</nowiki><br />
}}<br />
<br />
To get rid of the [Gmail]-Stuff (or [Google Mail] as in my case) in each mailbox name, it's possible to use separate Channels for each directory, and later merge them to a group:<br />
{{hc|~/.mbsyncrc|2=<br />
<nowiki><br />
Channel sync-googlemail-default<br />
Far :gmail-remote:<br />
Near :gmail-local:<br />
# Select some mailboxes to sync<br />
Patterns "INBOX" "arch"<br />
<br />
Channel sync-googlemail-sent<br />
Far :gmail-remote:"[Google Mail]/Gesendet"<br />
Near :gmail-local:sent<br />
Create Near<br />
<br />
Channel sync-googlemail-trash<br />
Far :gmail-remote:"[Google Mail]/Papierkorb"<br />
Near :gmail-local:trash<br />
Create Near<br />
<br />
# Get all the channels together into a group.<br />
Group googlemail<br />
Channel sync-googlemail-default<br />
Channel sync-googlemail-sent<br />
Channel sync-googlemail-trash<br />
</nowiki><br />
}}<br />
As you can see, name-translations are possible this way, as well.<br />
<br />
== Usage ==<br />
<br />
First make any folders that were specified as Maildirs.<br />
$ mkdir -p ~/.mail/gmail<br />
Then to retrieve the mail for a specific channel run:<br />
$ mbsync gmail<br />
or to retrive the mail for all channels:<br />
$ mbsync -a<br />
<br />
== Tips and tricks ==<br />
<br />
=== Using Path and/or Inbox on NTFS partitions ===<br />
<br />
Since ntfs partitions will not accept ; in a filename, you need to change your InfoDelimiter and your FieldDelimiter to something else, you can achieve this by globaly (outside any store or channel configuration) changing the later, like below:<br />
<br />
{{hc|~/.mbsyncrc|2=<br />
FieldDelimiter -<br />
}}<br />
<br />
=== Calling mbsync automatically ===<br />
<br />
==== With a timer ====<br />
<br />
If you want to automatically synchronize your mailboxes, isync can be started automatically with a [[systemd/User]] unit. The following service file can start the {{ic|mbsync}} command:<br />
<br />
{{hc|~/.config/systemd/user/mbsync.service|2=<br />
[Unit]<br />
Description=Mailbox synchronization service<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/mbsync -Va<br />
<br />
[Install]<br />
WantedBy=default.target<br />
}}<br />
<br />
The following timer configures {{ic|mbsync}} to be started 2 minutes after boot, and then every 5 minutes:<br />
<br />
{{hc|~/.config/systemd/user/mbsync.timer|2=<br />
[Unit]<br />
Description=Mailbox synchronization timer<br />
<br />
[Timer]<br />
OnBootSec=2m<br />
OnUnitActiveSec=5m<br />
Unit=mbsync.service<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
}}<br />
<br />
Once those two files are created, [[reload]] systemd, then [[enable]] and [[start]] {{ic|mbsync.timer}}, adding the {{ic|--user}} flag to {{ic|systemctl}}.<br />
<br />
{{Tip|The mbsync service now only runs after login. It's also possible to launch the systemd-user instances after boot if you configure [[Systemd/User#Automatic start-up of systemd user instances]].<br />
}}<br />
<br />
===== Integration with notmuch or mu4e =====<br />
<br />
If you want to run [[notmuch]] or mu/mu4e after automatically synchronizing your mails, it is preferable to modify the above {{ic|mbsync.service}} by adding a post-start hook, like below:<br />
<br />
{{hc|~/.config/systemd/user/mbsync.service|2=<br />
[Unit]<br />
Description=Mailbox synchronization service<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/mbsync -Va<br />
ExecStartPost=/usr/bin/notmuch new<br />
}}<br />
<br />
You can also index {{ic|mu}} by changing the {{ic|ExecStartPost}} line to {{ic|1=ExecStartPost=/usr/bin/mu index}}, or to {{ic|1=ExecStartPost=/usr/bin/emacsclient -e '(mu4e-update-index)'}} if you are running emacsclient and would like to index {{ic|mu4e}}.<br />
<br />
This modification assumes that you have already setup notmuch or mu/mu4e for your user. If the ExecStart command does not execute successfully, the ExecStartPost command will not execute, so be aware of this!<br />
<br />
==== With imapnotify ====<br />
<br />
[[Wikipedia:IMAP IDLE|IMAP IDLE]] is a way to get [[Wikipedia:Push Technology|push notifications]] to download new email, rather than polling the server intermittently. This has the advantage of saving bandwidth and delivering your mail as soon as it's available. Isync does not have native IDLE support, but we can use a program like [https://www.npmjs.com/package/imapnotify imapnotify] to call mbsync when you receive new email. For this example we will use the {{Pkg|goimapnotify}} package which is reported to work better with frequent network interruptions. <br />
<br />
Install {{Pkg|goimapnotify}} and create a configuration file for each mail server you want to poll. Note that the file name format, including the ''.conf'', is necessary if you want to use the provided systemd service:<br />
{{hc|~/.config/imapnotify/gmail.conf|<br />
<nowiki><br />
{<br />
"host": "imap.gmail.com",<br />
"port": 993,<br />
"tls": true,<br />
"tlsOptions": {<br />
"rejectUnauthorized": false<br />
},<br />
"username": "username@gmail.com",<br />
"password": "",<br />
"passwordCmd": "pass gmail | head -n1",<br />
"onNewMail": "mbsync gmail",<br />
"onNewMailPost": "",<br />
"boxes": [ "INBOX" ]<br />
}<br />
</nowiki>}}<br />
(You can view the full configuration options in the project's [https://gitlab.com/shackra/goimapnotify README].)<br />
<br />
[[Start/enable]] the {{ic|goimapnotify@gmail.service}} [[user unit]].<br />
<br />
Note that IMAP IDLE only triggers when new mail arrives, not when there is undownloaded mail on the server. For example, if you receive 100 emails with your computer powered off, then turn on your computer, imapnotify will still not download new mail until you receive another email. For this reason you may want to run mbsync [[Autostarting|once when you log in]].<br />
<br />
=== Using XOAUTH2 ===<br />
<br />
First install an XOAUTH2 SASL plugin, like {{AUR|cyrus-sasl-xoauth2-git}}.<br />
<br />
==== App registrations ====<br />
<br />
For all three OAuth2 helpers below you need to provide your own {{ic|client_id}} and {{ic|client_secret}} of your own or of a suitable FOSS registered application.<br />
<br />
In order to get a {{ic|client_id}} and {{ic|client_secret}}, you will need an app registration with the provider. You should create your own app registration if possible, otherwise you can use existing app registrations, such as [https://hg.mozilla.org/comm-central/file/tip/mailnews/base/src/OAuth2Providers.jsm Thunderbird's] (under {{ic|kIssuers}}), which are publicly available until dynamic client registration is supported.<br />
<br />
==== mailctl ====<br />
<br />
[https://github.com/pdobsan/mailctl mailctl] is a utility which provides IMAP/SMTP clients with renewal capabilities and authorization of OAuth2 credentials. [[install]] {{AUR|mailctl-bin}} and configure it according to its [[https://github.com/pdobsan/mailctl/blob/main/README.md README]].<br />
You can find configuration templates in /usr/share/mailctl.<br />
<br />
Before you are able to use mailctl with your credentials you need to authorize OAuth2 access by running the command below:<br />
<br />
mailctl authorize <service> <email><br />
<br />
Where <service> is your email provider (like ''google'') and <email> is your email address.<br />
<br />
After the authorization completed add {{ic|AuthMechs XOAUTH2}} and {{ic|PassCmd "mailctl access <email>"}} to the {{ic|IMAPAccount}} section in the {{ic|.mbsyncrc}}.<br />
<br />
==== oauth2token ====<br />
<br />
Install {{AUR|oauth2token}} and follow its [https://pypi.org/project/oauth2token/ README] to configure the account. It will be responsible for getting the current XOAUTH2 token using the account credentials every time mbsync needs to authenticate.<br />
<br />
Finally, add {{ic|AuthMechs XOAUTH2}} and {{ic|PassCmd "oauth2get <provider> <account>"}}, substituting {{ic|<provider>}} and {{ic|<account>}} with the values you used for {{ic|oauth2create}}, to the {{ic|IMAPAccount}} section in the {{ic|.mbsyncrc}}.<br />
<br />
==== mutt_oauth2.py ====<br />
<br />
{{ic|mutt_oauth2.py}} is known to work with Google and Microsoft accounts. Download [https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py mutt_oauth2.py] (make it executable and put in your {{ic|PATH}} if desired) and follow its [https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py.README README] for background and to configure the account.<br />
<br />
In short, you will need to modify the {{ic|ENCRYPTION_PIPE}} and {{ic|DECRYPTION_PIPE}} for your preferred encryption system as well as add the {{ic|client_id}} and {{ic|client_secret}} from an app registration with the provider (see [[#App registrations]]). Then to initialize your tokens, you run and answer the questions in:<br />
$ mutt_oauth2.py userid@myschool.edu.tokens --verbose --authorize<br />
To subsequently receive your access token (the script automatically handles renewing of tokens), you can run:<br />
$ mutt_oauth2.py userid@myschool.edu.tokens<br />
<br />
Finally, add {{ic|AuthMechs XOAUTH2}} and {{ic|PassCmd "mutt_oauth2.py userid@myschool.edu.tokens"}}, with the correct paths if necessary, to the {{ic|IMAPAccount}} section in the {{ic|.mbsyncrc}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== SSL error ===<br />
<br />
If you get the following error:<br />
{{bc|<br />
<nowiki><br />
SSL error connecting imap.gmail.com (108.177.125.109:993): self signed certificate<br />
</nowiki><br />
}}<br />
<br />
Since google enforce SNI when you use TLS 1.3, ensure to run at least isync v1.3.0<br />
See https://sourceforge.net/p/isync/isync/merge-requests/2/ for more details<br />
<br />
If you get certificate related errors like<br />
{{bc|<br />
<nowiki><br />
SSL error connecting pop.mail.com (193.222.111.111:143): error:00000012:lib(0):func(0):reason(18) <br />
</nowiki><br />
}}<br />
<br />
you may need to retrieve the server's certificates manually in order for mbsync to correctly verify it.<br />
<br />
==== Step #1: Get the certificates ====<br />
<br />
{{Accuracy|This may not always be needed, e.g. for gmail {{ic|CertificateFile /etc/ssl/certs/ca-certificates.crt}} in the config file may be suffcient|section=Step #1: Get the certificates}}<br />
<br />
{{bc|<br />
<nowiki><br />
$ mkdir ~/.cert<br />
$ openssl s_client -connect some.imap.server:port -showcerts 2>&1 < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sed -ne '1,/-END CERTIFICATE-/p' > ~/.cert/some.imap.server.pem<br />
</nowiki><br />
}}<br />
<br />
This will create a certificate file called {{ic|~/.cert/some.imap.server.pem}} (e.g. {{ic|~/.cert/imap.gmail.com.pem}}). Alternatively one can download [https://gist.githubusercontent.com/petRUShka/af96ae25ce8280729b9ea049b929f31d/raw/a79471ce8aee3f6d04049039adf870a53a524f7f/get_certs.sh get_certs.sh] and run it:<br />
<br />
{{bc|<br />
<nowiki><br />
$ mkdir ~/.cert<br />
$ wget https://gist.githubusercontent.com/petRUShka/af96ae25ce8280729b9ea049b929f31d/raw/a79471ce8aee3f6d04049039adf870a53a524f7f/get_certs.sh<br />
$ sh get_certs.sh some.imap.server port ~/.cert/<br />
</nowiki><br />
}}<br />
<br />
If you wish to do this manually, you may enter:<br />
<br />
{{bc|<br />
<nowiki><br />
$ openssl s_client -connect some.imap.server:port -showcerts<br />
</nowiki><br />
}}<br />
<br />
and it will display output something like:<br />
<br />
{{bc|<br />
<nowiki><br />
CONNECTED(00000003)<br />
depth=1 C = US, O = Google Inc, CN = Google Internet Authority<br />
verify error:num=20:unable to get local issuer certificate<br />
verify return:0<br />
---<br />
Certificate chain<br />
0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=imap.gmail.com<br />
i:/C=US/O=Google Inc/CN=Google Internet Authority<br />
-----BEGIN CERTIFICATE-----<br />
MIIDgDCCAumgAwIBAgIKO3MmiwAAAABopTANBgkqhkiG9w0BAQUFADBGMQswCQYD<br />
VQQGEwJVUzETMBEGA1UEChMKR29vZ2xlIEluYzEiMCAGA1UEAxMZR29vZ2xlIElu<br />
dGVybmV0IEF1dGhvcml0eTAeFw0xMjA5MTIxMTU1NDlaFw0xMzA2MDcxOTQzMjda<br />
MGgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1N<br />
b3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMRcwFQYDVQQDEw5pbWFw<br />
LmdtYWlsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2OmU9DjI+DFQ<br />
ThqIN4vL6EqZbzH0ejLKcc+zhxsq9BU5hXohSJ1sS5FUU2vReDKk8fd+ZR3cWtpf<br />
CTYAUSvdnz1ZFjESSzyUBmGRqByhoc0yqdfb61NosA4CDaO+z7DtAgKyecqnAJad<br />
TPYYf9aLk/UgJuc6GseitjzFYonXi6ECAwEAAaOCAVEwggFNMB0GA1UdJQQWMBQG<br />
CCsGAQUFBwMBBggrBgEFBQcDAjAdBgNVHQ4EFgQUFuLyTg2NcsyaEESytZbLbQan<br />
YIowHwYDVR0jBBgwFoAUv8Aw6/VDET5nup6R+/xq2uNrEiQwWwYDVR0fBFQwUjBQ<br />
oE6gTIZKaHR0cDovL3d3dy5nc3RhdGljLmNvbS9Hb29nbGVJbnRlcm5ldEF1dGhv<br />
cml0eS9Hb29nbGVJbnRlcm5ldEF1dGhvcml0eS5jcmwwZgYIKwYBBQUHAQEEWjBY<br />
MFYGCCsGAQUFBzAChkpodHRwOi8vd3d3LmdzdGF0aWMuY29tL0dvb2dsZUludGVy<br />
bmV0QXV0aG9yaXR5L0dvb2dsZUludGVybmV0QXV0aG9yaXR5LmNydDAMBgNVHRMB<br />
Af8EAjAAMBkGA1UdEQQSMBCCDmltYXAuZ21haWwuY29tMA0GCSqGSIb3DQEBBQUA<br />
A4GBAC1LV7tM6pcyVJLcwdPml4DomtowsjTrqvy5ZFa3SMKANK0iZBgFu74O0THX<br />
8SxP/vn4eAs0yRQxcT1ZuoishLGQl5NoimLaQ4BGQnzFQHDJendfaVKDl21GenJp<br />
is72sIrAeprsVU8PbNsllUamWsIjKr3DH5xQdH54hDtzQojY<br />
-----END CERTIFICATE-----<br />
1 s:/C=US/O=Google Inc/CN=Google Internet Authority<br />
i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority<br />
-----BEGIN CERTIFICATE-----<br />
MIICsDCCAhmgAwIBAgIDC2dxMA0GCSqGSIb3DQEBBQUAME4xCzAJBgNVBAYTAlVT<br />
MRAwDgYDVQQKEwdFcXVpZmF4MS0wKwYDVQQLEyRFcXVpZmF4IFNlY3VyZSBDZXJ0<br />
aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDkwNjA4MjA0MzI3WhcNMTMwNjA3MTk0MzI3<br />
WjBGMQswCQYDVQQGEwJVUzETMBEGA1UEChMKR29vZ2xlIEluYzEiMCAGA1UEAxMZ<br />
R29vZ2xlIEludGVybmV0IEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw<br />
gYkCgYEAye23pIucV+eEPkB9hPSP0XFjU5nneXQUr0SZMyCSjXvlKAy6rWxJfoNf<br />
NFlOCnowzdDXxFdF7dWq1nMmzq0yE7jXDx07393cCDaob1FEm8rWIFJztyaHNWrb<br />
qeXUWaUr/GcZOfqTGBhs3t0lig4zFEfC7wFQeeT9adGnwKziV28CAwEAAaOBozCB<br />
oDAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFL/AMOv1QxE+Z7qekfv8atrjaxIk<br />
MB8GA1UdIwQYMBaAFEjmaPkr0rKV10fYIyAQTzOYkJ/UMBIGA1UdEwEB/wQIMAYB<br />
Af8CAQAwOgYDVR0fBDMwMTAvoC2gK4YpaHR0cDovL2NybC5nZW90cnVzdC5jb20v<br />
Y3Jscy9zZWN1cmVjYS5jcmwwDQYJKoZIhvcNAQEFBQADgYEAuIojxkiWsRF8YHde<br />
BZqrocb6ghwYB8TrgbCoZutJqOkM0ymt9e8kTP3kS8p/XmOrmSfLnzYhLLkQYGfN<br />
0rTw8Ktx5YtaiScRhKqOv5nwnQkhClIZmloJ0pC3+gz4fniisIWvXEyZ2VxVKfml<br />
UUIuOss4jHg7y/j7lYe8vJD5UDI=<br />
-----END CERTIFICATE-----<br />
---<br />
Server certificate<br />
subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=imap.gmail.com<br />
issuer=/C=US/O=Google Inc/CN=Google Internet Authority<br />
---<br />
No client certificate CA names sent<br />
---<br />
SSL handshake has read 2108 bytes and written 350 bytes<br />
---<br />
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-RC4-SHA<br />
Server public key is 1024 bit<br />
Secure Renegotiation IS supported<br />
Compression: NONE<br />
Expansion: NONE<br />
SSL-Session:<br />
Protocol : TLSv1.1<br />
Cipher : ECDHE-RSA-RC4-SHA<br />
Session-ID: 77136647F42633D82DEDFBB9EB62AB516547A3697D83BD1884726034613C1C09<br />
Session-ID-ctx: <br />
Master-Key: 635957FBA0762B10694560488905F73BDD2DB674C41970542ED079446F27234E2CA51CF26938B8CA56DF5BBC71E429A7<br />
Key-Arg : None<br />
PSK identity: None<br />
PSK identity hint: None<br />
SRP username: None<br />
TLS session ticket lifetime hint: 100800 (seconds)<br />
TLS session ticket:<br />
0000 - d6 5b a0 a7 10 0e 64 04-72 93 7c 9f 94 fa 07 57 .[....d.r.|....W<br />
0010 - f1 8b 9d 24 8b 9d 1b f3-a8 b1 4d 2c a9 00 e1 82 ...$......M,....<br />
0020 - 00 83 1e 3f e5 f2 b2 2c-d2 a8 87 83 16 02 0d 1e ...?...,........<br />
0030 - bf b6 c1 d6 75 21 04 e6-63 6b ab 5b ed 94 7a 30 ....u!..ck.[..z0<br />
0040 - 1a d0 aa 44 c2 04 9b 10-06 28 b5 7b a0 43 a6 0d ...D.....(.{.C..<br />
0050 - 3b 4a 85 1f 2e 07 0a e1-32 9b bd 5d 65 41 4c e2 ;J......2..]eAL.<br />
0060 - 7c d7 43 ec c4 18 77 53-b5 d4 84 b4 c9 bd 51 d6 |.C...wS......Q.<br />
0070 - 2d 4f 2e 10 a6 ed 38 c5-8e 9d f8 8b 8a 63 3f 7b -O....8......c?{<br />
0080 - ee e6 b8 bf 7a f8 b8 e8-47 92 84 f1 9b 0c 63 30 ....z...G.....c0<br />
0090 - 76 d8 e1 44 v..D<br />
<br />
Start Time: 1352632558<br />
Timeout : 300 (sec)<br />
Verify return code: 20 (unable to get local issuer certificate)<br />
---<br />
* OK Gimap ready for requests from 108.78.162.240 o67if11168976yhc.67<br />
</nowiki><br />
}}<br />
<br />
Simply copy the first block that begins with {{ic|-----BEGIN CERTIFICATE-----}} and ends with {{ic|-----END CERTIFICATE-----}}, paste into a file, and save with a .pem extension (this is necessary for the next step). Older instructions state that, with Gmail, both certificate blocks must be saved but on testing this was found to be unnecessary.<br />
<br />
Now, copy the root issuer certificate to your local certificate folder. In this example (Gmail), the root issuer is Equifax Secure Certificate Authority. This certificate is included in the {{pkg|ca-certificates}} package.<br />
<br />
{{bc|<br />
<nowiki><br />
cp /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt ~/.cert/Equifax_Secure_CA.pem<br />
</nowiki><br />
}}<br />
<br />
==== Step #2: Setup mbsync ====<br />
<br />
Configure mbsync to use that certificate:<br />
<br />
{{hc|~/.mbsyncrc|2=<br />
<nowiki><br />
IMAPAccount gmail<br />
Host imap.gmail.com<br />
# ...<br />
CertificateFile ~/.cert/imap.gmail.com.pem<br />
<br />
</nowiki><br />
}}<br />
<br />
=== BAD Command with Exchange 2003 ===<br />
<br />
When connecting to an MS Exchange 2003 server, there could be problems when using pipelining (i.e. executing multiple imap commands concurrently). Such an issue could look as follows:<br />
{{hc|mbsync -V exchange|<br />
<nowiki><br />
>>> 9 SELECT "arch"^M<br />
* 250 EXISTS<br />
* 0 RECENT<br />
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)<br />
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags<br />
* OK [UNSEEN 241] Is the first unseen message<br />
* OK [UIDVALIDITY 4352] UIDVALIDITY value<br />
9 OK [READ-WRITE] SELECT completed.<br />
>>> 10 UID FETCH 1:1000000000 (UID FLAGS)^M<br />
* 1 FETCH (UID 1 FLAGS (\Seen \Answered))<br />
* 2 FETCH (UID 2 FLAGS (\Seen \Answered))<br />
...<br />
* 249 FETCH (UID 696 FLAGS ())<br />
* 250 FETCH (UID 697 FLAGS (\Seen))<br />
10 OK FETCH completed.<br />
>>> 11 APPEND "arch" (\Seen) {4878+}^M<br />
(1 in progress) >>> 12 UID FETCH 697 (BODY.PEEK[])^M<br />
(2 in progress) >>> 13 UID STORE 696 +FLAGS.SILENT (\Deleted)^M<br />
12 BAD Command is not valid in this state.<br />
</nowiki><br />
}}<br />
So command 9 is to select a new folder, command 10 checks the mail and commands 11, 12 and 13 run in parallel, writing/getting/flagging a mail. In this case, the Exchange server would terminate the connection after the BAD return value and go on to the next channel. (And if all went well in this channel, mbsync would return with 0.) After setting<br />
PipelineDepth 1<br />
in the IMAPStore config part of the Exchange, this problem did not occur any more.<br />
<br />
=== Emails on remote server have the wrong date ===<br />
<br />
This fix works when syncing with fastmail, but it likely applies to other services as well.<br />
<br />
If you move an email to a new folder using an email client, and mbsync causes the email to appear with the wrong date on<br />
the server, add this to your configuration file:<br />
CopyArrivalDate yes<br />
For example, without this setting, moving an old email from Inbox to Archive using mu4e and then<br />
syncing to fastmail with mbsync will cause the email to appear in Archive but with the date of<br />
the sync.<br />
<br />
mbsync uses mtime of email message when uploading from maildir to imap server. You can use [https://gist.github.com/artizirk/877ce9d30159323aac037e2a2af74509 fix_maildir_mail_mtime.py] script to set mtime from email header.<br />
<br />
== External links ==<br />
<br />
*[http://isync.sourceforge.net/ Home page]<br />
*[https://sourceforge.net/projects/isync/ Sourceforge page]<br />
*[https://kevin.deldycke.com/2012/08/gmail-backup-mbsync/ backing up gmail with mbsync]<br />
*[https://www.cyberciti.biz/faq/test-ssl-certificates-diagnosis-ssl-certificate/ How To Verify SSL Certificate From A Shell Prompt]</div>Petrushttps://wiki.archlinux.org/index.php?title=Msmtp&diff=733708Msmtp2022-06-23T21:50:53Z<p>Petrus: comprehensive Oauth2 solution</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Email clients]]<br />
[[ja:Msmtp]]<br />
{{Related articles start}}<br />
{{Related|Mail server}}<br />
{{Related articles end}}<br />
<br />
[https://marlam.de/msmtp/ msmtp] is a very simple and easy to use SMTP client with fairly complete [[sendmail]] compatibility.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|msmtp}} package. Additionally, [[install]] {{Pkg|msmtp-mta}}, which creates a sendmail alias to msmtp.<br />
<br />
== Basic setup ==<br />
<br />
Since msmtp version 1.8.6 you can place your user configuration either at {{ic|~/.msmtprc}} or {{ic|$XDG_CONFIG_HOME/msmtp/config}}. The following is an example of a msmtp configuration (the file is based on the per-user example file located at {{ic|/usr/share/doc/msmtp/msmtprc-user.example}}; the system configuration file belongs at {{ic|/etc/msmtprc}} and its corresponding example file is located at {{ic|/usr/share/doc/msmtp/msmtprc-system.example}}).<br />
<br />
{{Tip|If using Gmail you will need to either:<br />
* If you use two factor authentication: [https://myaccount.google.com/apppasswords create an app password].<br />
* Otherwise: [https://myaccount.google.com/lesssecureapps allow less secure apps] (not recommended).<br />
}}<br />
<br />
{{hc|~/.msmtprc|<br />
# Set default values for all following accounts.<br />
defaults<br />
auth on<br />
tls on<br />
tls_trust_file /etc/ssl/certs/ca-certificates.crt<br />
logfile ~/.msmtp.log<br />
<br />
# Gmail<br />
account gmail<br />
host smtp.gmail.com<br />
port 587<br />
from ''username''@gmail.com<br />
user ''username''<br />
password ''plain-text-password''<br />
<br />
# A freemail service<br />
account freemail<br />
host smtp.freemail.example<br />
from joe_smith@freemail.example<br />
...<br />
<br />
# Set a default account<br />
account default : gmail<br />
}}<br />
<br />
{{Note|If you are using SSL/TLS and receive a "Server sent empty reply" error message, see [[#Server sent empty reply]].}}<br />
<br />
The ''user'' configuration file must be explicitly readable/writeable by its owner or msmtp will fail:<br />
<br />
$ chmod 600 ~/.msmtprc<br />
<br />
To avoid saving the password in plain text in the configuration file, use ''passwordeval'' to launch an external program, or see the [[#Password management]] section below. This example using Gnu PG is commonly used to perform decryption of a password:<br />
<br />
echo -e "password\n" | gpg --encrypt -o .msmtp-gmail.gpg # enter id (email...)<br />
<br />
{{Warning |Most shells save command history(e.g. .bash_history .zhistory). To avoid this, use gpg with shell stdin: {{ic|gpg --encrypt -o .msmtp-gmail.gpg -r <email> -}}. The ending dash is not a typo, rather it causes gpg to use stdin. After running that snippet of code, type in your password, press enter, and press Control-d so gpg can encrypt your password.}}<br />
<br />
{{hc|~/.msmtprc|<br />
passwordeval "gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.msmtp-gmail.gpg"<br />
}}<br />
<br />
== Using the mail command ==<br />
<br />
To send mails using the {{ic|mail}} command you must install the package {{Pkg|s-nail}}, which also provides the {{ic|mailx}} command. You will also need to provide a {{ic|sendmail}}-compatible MTA, either by installing {{Pkg|msmtp-mta}} (which symlinks {{ic|sendmail}} to {{ic|msmtp}}) or by editing {{ic|/etc/mail.rc}} to set the sendmail path:<br />
<br />
{{hc|/etc/mail.rc|2=<br />
set mta=/usr/bin/msmtp<br />
}}<br />
<br />
A {{ic|.msmtprc}} file will need to be in the home of every user who wants to send mail or alternatively the system wide {{ic|/etc/msmtprc}} can be used.<br />
<br />
msmtp also understands aliases. Add the following line to the defaults section of msmtprc or your local configuration file:<br />
<br />
{{hc|/etc/msmtprc|2=<br />
aliases /etc/aliases<br />
}}<br />
<br />
and create an aliases file in {{ic|/etc}}<br />
<br />
{{hc|/etc/aliases|2=<br />
# Example aliases file<br />
<br />
# Send root to Joe and Jane<br />
root: joe_smith@example.com, jane_chang@example.com<br />
<br />
# Send everything else to admin<br />
default: admin@domain.example<br />
}}<br />
<br />
== Test functionality ==<br />
<br />
The account option ({{ic|1=--account=,-a}}) tells which account to use as sender:<br />
<br />
$ echo "hello there username." | msmtp -a default ''username''@domain.com<br />
<br />
Or, send both a subject and a body:<br />
<br />
$ printf "Subject: Test\n\nhello there username." | msmtp -a default ''username''@domain.com<br />
<br />
Or, with the addresses in a file:<br />
<br />
{{bc|<br />
To: ''username''@domain.com<br />
From: ''username''@gmail.com<br />
Subject: A test<br />
<br />
Hello there.<br />
}}<br />
<br />
$ cat test.mail | msmtp -a default <username>@domain.com<br />
<br />
{{Tip|You can use ''--read-envelope-from'' instead of ''-a default'' to automatically chose account by ''From:'' field in message you are going to send.}}<br />
<br />
== Cronie default email client ==<br />
<br />
{{Out of date|Arch uses [[systemd/Timers]] instead of cronie}}<br />
<br />
To make [[Cron#Cronie|Cronie]] use msmtp rather than sendmail, make sure {{Pkg|msmtp-mta}} is installed, or edit the {{ic|cronie.service}} systemd unit:<br />
<br />
{{hc|/etc/systemd/system/cronie.service.d/msmtp.conf|2=<br />
[Service]<br />
ExecStart=<br />
ExecStart=/usr/bin/crond -n -m '/usr/bin/msmtp -t'<br />
}}<br />
<br />
Then you must tell cronie or msmtp what your email address is, either by:<br />
<br />
# Add to {{ic|/etc/msmtprc}}: {{bc|aliases /etc/aliases}} and create {{ic|/etc/aliases}}: {{bc|your_username: email@address.com}}— OR —.<br />
* Add a {{ic|MAILTO}} line to the crontab: {{bc|1=MAILTO=email@address.com}}<br />
<br />
== Password management ==<br />
<br />
Passwords for msmtp [https://marlam.de/msmtp/msmtp.html#Authentication can be stored] in plaintext, encrypted files, or a keyring.<br />
<br />
=== GNOME Keyring ===<br />
<br />
Storing passwords in [[GNOME Keyring]] is supported natively in msmtp. Setup the keyring as described on the linked wiki page and install {{Pkg|libsecret}}. Then, store a password by running:<br />
<br />
secret-tool store --label=msmtp host ''smtp.your.domain'' service smtp user ''yourusername''<br />
<br />
''msmtp'' should now find the password automatically.<br />
<br />
=== GnuPG ===<br />
<br />
The {{ic|password}} directive may be omitted. In that case, if the account in question has {{ic|auth}} set to a legitimate value other than {{ic|off}}, invoking msmtp from an interactive shell will ask for the password before sending mail. msmtp will not prompt if it has been called by another type of application, such as [[Mutt]]. For such cases, the {{ic|--passwordeval}} parameter<br />
can be used to call an external keyring tool like [[GnuPG]].<br />
<br />
To do this, set up [[GnuPG]], including [[GnuPG#gpg-agent|gpg-agent]] to avoid having to enter the password every time. Then, create an encrypted password file for msmtp, as follows. Create a secure directory with {{ic|700}} permissions located on a [[tmpfs]] to avoid writing the unencrypted password to the disk. In that directory create a plain text file with the mail account password. Then, encrypt the file with your private key:<br />
<br />
$ gpg --default-recipient-self -e ''/path/to/plain/password''<br />
<br />
Remove the plain text file and move the encrypted file to the final location, e.g. {{ic|~/.mail/.msmtp-credentials.gpg}}. In {{ic|~/.msmtprc}} add:<br />
<br />
{{hc|~/.msmtprc|<br />
passwordeval "gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.mail/.msmtp-credentials.gpg"<br />
}}<br />
<br />
Normally this is sufficient for a GUI password prompt to appear when, for example, sending a message from [[Mutt]]. If gpg prompt for the passphrase cannot be issued, then start the [[GPG#gpg-agent|gpg-agent]] before. A simple hack to start the agent is to execute a external command in your muttrc using the backtick {{ic|`''command''`}} syntax. For example, you can put something like the following in your muttrc:<br />
<br />
{{hc|muttrc|2=<br />
set my_msmtp_pass=`gpg -d mypwfile.gpg`<br />
}}<br />
<br />
Mutt will execute this when it starts, gpg-agent will cache your password, msmtp will be happy and you can send mail. <br />
<br />
{{Note| If you do this, you will have to restart mutt after gpg-agent clears the password to start sending emails again.}}<br />
<br />
An alternative is to place passwords in {{ic|~/.netrc}}, a file that can act as a common pool for msmtp, [[OfflineIMAP]], and associated tools.<br />
<br />
=== pass ===<br />
<br />
You may store your credentials inside of the [[pass]] password manager.<br />
<br />
If you are using your main password (which is customarily stored in the first line of your pass file) to login into your SMTP server, you can add the following to your {{ic|.msmptrc}}:<br />
<br />
{{hc|~/.msmtprc|<br />
passwordeval "pass your_email_password_entry {{!}} head -n1"<br />
}}<br />
<br />
If you are using GMail, and have set up an [https://myaccount.google.com/apppasswords app password], the following configuration will suit you better.<br />
Save your app password inside your {{ic|pass}} password file, but with a {{ic|msmtp:}} prefix:<br />
<br />
{{hc|your_email_password_entry|<br />
your_main_password<br />
<br />
login: your_username<br />
url: the_url_of_your_email<br />
'''msmtp: your_msmtp_app_password'''}}<br />
<br />
Then add the following to your {{ic|.msmptrc}}:<br />
{{hc|~/.msmtprc|<br />
passwordeval "pass your_email_password_entry {{!}} awk '/^msmtp:/ { print $2; }'"<br />
}}<br />
<br />
In either case, trying to send an email with msmtp will trigger {{ic|pass}}, which may ask you for your {{ic|pass}} master password if you have not entered it recently.<br />
<br />
== Miscellaneous ==<br />
<br />
=== Using msmtp offline ===<br />
<br />
Although msmtp is great, it requires that you be online to use it. This is not ideal for people on laptops with intermittent connections to the Internet or dialup users. Several scripts have been written to remedy this fact, collectively called msmtpqueue.<br />
<br />
The scripts are installed under {{ic|/usr/share/doc/msmtp/msmtpqueue}}. You might want to copy the scripts to a convenient location on your computer, ({{ic|/usr/local/bin}} is a good choice).<br />
<br />
Finally, change your MUA to use msmtp-enqueue.sh instead of msmtp when sending e-mail. By default, queued messages will be stored in {{ic|~/.msmtpqueue}}. To change this location, change the {{ic|1=QUEUEDIR=$HOME/.msmtpqueue}} line in the scripts (or delete the line, and export the QUEUEDIR variable in {{ic|.bash_profile}} like so: {{ic|1=export QUEUEDIR="$XDG_DATA_HOME/msmtpqueue"}}). <br />
<br />
When you want to send any mail that you have created and queued up run:<br />
<br />
$ /usr/local/bin/msmtp-runqueue.sh<br />
<br />
Adding {{ic|/usr/local/bin}} to your PATH can save you some keystrokes if you are doing it manually. The README file that comes with the scripts has some handy information, reading it is recommended.<br />
<br />
=== Vim syntax highlighting ===<br />
<br />
The msmtp source distribution includes an {{ic|msmtprc}} syntax-highlighting script for [[Vim]], which is available at {{ic|/usr/share/vim/vimfiles/syntax/msmtp.vim}}. The filetype is not detected automatically. The easiest way to enable it is by adding a [http://vimdoc.sourceforge.net/htmldoc/options.html#modeline modeline] at the top or bottom of the file(s), i.e.:<br />
<br />
# vim:filetype=msmtp<br />
<br />
=== Send mail with PHP using msmtp ===<br />
<br />
Look for {{ic|sendmail_path}} option in your {{ic|php.ini}} and edit like this:<br />
<br />
sendmail_path = "/usr/bin/msmtp -C /path/to/your/config -t"<br />
<br />
Note that you '''can not''' use a user configuration file (ie: one under ~/) if you plan on using msmtp as a sendmail replacement with php or something similar.<br />
In that case just create /etc/msmtprc, and remove your user configuration (or not if you plan on using it for something else). Also make sure it is readable by whatever you are using it with (php, django, etc...).<br />
<br />
From the msmtp manual: ''Accounts defined in the user configuration file override accounts from the system configuration file. The user configuration file must have no more permissions than user read/write''<br />
<br />
So it is impossible to have a conf file under ~/ and have it still be readable by the php user.<br />
<br />
To test it place this file in your php enabled server or using php-cli.<br />
<br />
<?php<br />
mail("your@email.com", "Test email from PHP", "msmtp as sendmail for PHP");<br />
?><br />
<br />
{{ic|php-fpm}} will fail to send mails and logs the warning: {{ic|PHP Warning: mail(mail.log): failed to open stream}} unless you set the permissions of your /etc/msmtprc to user read/write (600).<br />
<br />
=== OAuth2 authentication for Gmail ===<br />
<br />
While '''msmtp''' can use OAuth2 access tokens in particular, it can be used with '''gmail''', it lacks the ability to renew and/or authorize OAuth2 credentials. A comprehensive solution is using the [https://github.com/pdobsan/mailctl mailctl] utility which provides IMAP/SMTP clients with the capabilities of renewal and authorization of OAuth2 credentials.<br />
<br />
Example config how to use '''mailctl''':<br />
<br />
# account at Google with oauth2 access <br />
account YOUR_EMAIL_NAME@gmail.com <br />
from YOUR_EMAIL_NAME@gmail.com <br />
user YOUR_EMAIL_NAME@gmail.com <br />
auth oauthbearer <br />
passwordeval mailctl access YOUR_EMAIL_NAME@gmail.com <br />
host smtp.gmail.com <br />
port 587 <br />
tls on <br />
tls_trust_file /etc/ssl/certs/ca-certificates.crt <br />
<br />
Access token renewal happens automatically in the background transparent to the user.<br />
'''mailctl''' is available from AUR as a binary package: {{AUR|mailctl-bin}}<br />
<br />
There are other scripted methods, see below.<br />
<br />
==== Wrapper on oauth2.py ====<br />
<br />
This is a scripted method, using the [https://marlam.de/msmtp/msmtp.html#Authentication msmtp setting oauthbearer] for authentication.<br />
<br />
Once you have your [https://developers.google.com/gmail/api Gmail API] setup, you can implement the wrapper script [https://github.com/tenllado/dotfiles/tree/master/config/msmtp oauth2token] (that employs [https://manpages.ubuntu.com/manpages/trusty/man1/secret-tool.1.html secret-tool]) or an [https://github.com/harriott/ArchBuilds/blob/master/jo/mail/oauth2tool.sh adaptation of oauth2token] (that employs [https://www.passwordstore.org/ pass]).<br />
<br />
An {{ic|msmtp}} configuration would be adapted thus:<br />
<br />
auth oauthbearer<br />
...<br />
passwordeval <call_to_wrapper_script><br />
<br />
If you comment out the last line, {{ic|msmtp}} will request you for the token that {{ic|oauth2.py}} provides you, which is normally valid for one hour.<br />
<br />
==== OAuth2 hack ====<br />
<br />
{{Note|This method may work, but uses outdated tools.}}<br />
<br />
To use XOAUTH2 authentication with Gmail (see [https://developers.google.com/gmail/imap/xoauth2-protocol official information]), you can install the {{AUR|msmtp-oauth2}} package. The package does a small hack so that the plain authentication method will send the {{ic|AUTH XOAUTH2 password}} instead of the {{ic|AUTH PLAIN ...}}, effectively disabling plain authentication and enabling XOAUTH2. Your {{ic|msmtp}} would be adapted as follows:<br />
<br />
from your@gmail_login_email<br />
tls on<br />
tls_starttls on<br />
tls_certcheck off<br />
auth plain<br />
user any_thing_here<br />
passwordeval "get-gmail-token"<br />
<br />
The {{ic|get-gmail-token}} script can be found from the source files of the ''msmtp-oauth2'' package. See more information on [https://www.bytereef.org/howto/oauth2/getmail.html getmail link] about how this works. And see [https://developers.google.com/gmail/api/quickstart/python Gmail API quickstart] for instruction on registering a Gmail APP and authorizing it to access emails.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Issues with TLS ===<br />
<br />
If you see the following message:<br />
<br />
msmtp: TLS certificate verification failed: the certificate hasn't got a known issuer<br />
<br />
It probably means your tls_trust_file is not right.<br />
<br />
Just follow the [https://marlam.de/msmtp/msmtp.html#Transport-Layer-Security fine manual]. It explains you how to find out the server certificate issuer of a given smtp server. Then you can explore the {{ic|/usr/share/ca-certificates/}} directory to find out if by any chance, the certificate you need is there. If not, you will have to get the certificate on your own. If you are using your own certificate, you can make msmtp trust it by adding the following to your {{ic|~/.msmtprc}}:<br />
<br />
tls_fingerprint <SHA1 (recommended) or MD5 fingerprint of the certificate><br />
<br />
If you are trying to send mail through GMail and are receiving this error, have a look at [https://www.mail-archive.com/msmtp-users@lists.sourceforge.net/msg00141.html this] thread or just use the second GMail example above.<br />
<br />
If you are completely desperate, but are 100% sure you are communicating with the right server, you can always temporarily disable the cert check:<br />
<br />
$ msmtp --tls-certcheck off<br />
<br />
If you see the following message:<br />
<br />
msmtp: TLS handshake failed: the operation timed out<br />
<br />
You may be affected by this [https://bugs.archlinux.org/task/44994 bug]. Recompile with {{ic|1=--with-ssl=openssl}} (msmtp is compiled with GnuTLS by default).<br />
<br />
=== Server sent empty reply ===<br />
<br />
If you get a "server sent empty reply" error, this probably means the mail server does not support STARTTLS over port 587, but requires TLS over port 465.<br />
<br />
To let msmtp use TLS over port 465, add the following line to {{ic|~/.msmtprc}}:<br />
<br />
tls_starttls off<br />
<br />
=== Issues with GSSAPI ===<br />
<br />
If you get the following error<br />
<br />
GNU SASL: GSSAPI error in client while negotiating security context in gss_init_sec_context() in SASL library. This is most likely due insufficient credentials or malicious interactions.<br />
<br />
Try changing your auth setting to plain, instead of gssapi in your .msmtprc file [https://bbs.archlinux.org/viewtopic.php?id=138727]:<br />
<br />
auth plain</div>Petrushttps://wiki.archlinux.org/index.php?title=Fdm&diff=733707Fdm2022-06-23T21:48:46Z<p>Petrus: some more explanation</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Mail server]]<br />
[[Category:Mail retrieval agents]]<br />
[[es:Fdm]]<br />
[[ja:Fdm]]<br />
{{Related articles start}}<br />
{{Related|Mail server}}<br />
{{Related articles end}}<br />
[https://github.com/nicm/fdm fdm] (''fetch and deliver mail''), is a simple program for delivering and filtering mail. Comparing it to other same-purposed applications shows that it has similarities with [[Mutt]]'s very focused design principles.<br />
<br />
== Installing ==<br />
<br />
[[Install]] the {{Pkg|fdm}} package or the {{AUR|fdm-git}} package.<br />
<br />
== Configuration ==<br />
<br />
'''fdm''' can be configured trough a configuration file. <br />
Default is {{ic|~/.fdm.conf}}, or {{ic| /etc/fdm.conf}} if that does not exist.<br />
For full details refer to the manual pages {{man|1|fdm}}, {{man|5|fdm.conf}} and the<br />
{{ic|/usr/share/doc/fdm-git/MANUAL}}.<br />
<br />
=== mbox ===<br />
<br />
Alpine uses the mbox format, so we need to set up some files that we will be editing:<br />
$ cd<br />
$ mkdir mail<br />
$ touch mail/INBOX .fdm.conf <br />
$ chmod 600 .fdm.conf mail/INBOX<br />
<br />
=== maildir ===<br />
<br />
Mutt prefers a capitalized mail directory, and is able to use the maildir format. If you plan on using Mutt do the following setup:<br />
$ cd<br />
$ touch .fdm.conf; chmod 600 .fdm.conf<br />
$ mkdir -p Mail/INBOX/{new,cur,tmp}<br />
<br />
=== An example configuration ===<br />
<br />
Edit {{ic|.fdm.conf}}, and add your email accounts and basic filter rules. Use mbox or maildir, but not both.<br />
<br />
{{hc|.fdm.conf|<br />
## Accounts and rules for:<br />
#> foo@example.com<br />
#> bar@gmail.com<br />
## Last edit 21-Dec-09<br />
<br />
# Catch-all action (mbox):<br />
action "inbox" mbox "%h/mail/INBOX"<br />
# Catch-all action (maildir):<br />
# action "inbox" maildir "%h/Mail/INBOX"<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass "supersecret"<br />
<br />
account "bar" imaps server "imap.gmail.com"<br />
user "bar@gmail.com" pass "evenmoresecret"<br />
<br />
# Match all mail and deliver using the 'inbox' action.<br />
match all action "inbox"<br />
}}<br />
<br />
This will collect the mail from the listed accounts and deliver it to the INBOX folder that we made. Refer to the {{man|1|fdm}} man page for specifics on how to connect to other types of mail servers (POP3 for example).<br />
<br />
{{Tip|You can also specify your login name and/or password in the {{ic|.netrc}} file.}}<br />
<br />
== Password Management ==<br />
<br />
Passwords for email accounts can be stored as plain text in the config file or<br />
can be requested from a password manager or key-ring via a shell command, in the<br />
format of {{ic|$(cmd ...)}}<br />
<br />
=== Using a password manager ===<br />
<br />
Here is an example using '''pass''':<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass $(pass foo-email-entry | head -1)<br />
<br />
=== OAuth2 authentication, gmail ===<br />
<br />
While fdm can use OAuth2 access tokens in particular, it can be used with '''gmail''', it lacks the ability to renew and/or authorize OAuth2 credentials. A comprehensive solution is using the [https://github.com/pdobsan/mailctl mailctl] utility which provides IMAP/SMTP clients with the capabilities of renewal and authorization of OAuth2 credentials.<br />
<br />
Example config:<br />
<br />
account "foo" imaps server "imap.gmail.com"<br />
user "foo@gmail.com"<br />
pass $(mailctl access foo@gmail.com)<br />
oauthbearer<br />
<br />
Access token renewal happens automatically in the background transparent to the user.<br />
'''mailctl''' is available from the AUR as a binary package: {{AUR|mailctl-bin}}<br />
<br />
=== Running from cron ===<br />
<br />
While the above examples work fine for interactive use, using them from a cron job is<br />
a bit more involved since some of the programs invoked might expect certain environments.<br />
One can work around that by using wrapper scripts and exporting the needed environment variables<br />
Here are a few tricks for such scripts:<br />
<br />
...<br />
# for pass<br />
export PASSWORD_STORE_DIR=~/.local/var/password-store<br />
...<br />
# when using gnome's keyring<br />
# secret-tool can't live without these two envvars<br />
# so we fake them for the case this script runs in a cron job<br />
export DISPLAY=${DISPLAY:-:0}<br />
export DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-unix:path=/run/user/$UID/bus}<br />
...<br />
<br />
== Testing ==<br />
<br />
Once you have this setup to your satisfaction, attempt to collect your mail by manually running fdm.<br />
$ fdm -kv fetch<br />
<br />
This will keep your mail untouched on the server incase there are errors. Look over the output to make sure everything worked as planned. Open your favorite mail reader (MUA) and make sure that you can read the mail that was just delivered.<br />
<br />
== Extended usage ==<br />
<br />
=== Additional filtering ===<br />
<br />
If you want to have mail from a certain account go to a specific mailbox, you could add the following lines to your {{ic|fdm.conf}} file. From the configuration file above, if you wanted to filter the mail from {{ic|''bar@gmail.com''}} into its own folder {{ic|''bar-mail''}}, you would add this below the existing "action" line:<br />
<br />
action ''bar-deliver'' mbox "%h/mail/''bar-mail''"<br />
<br />
Change the {{ic|mbox}} to {{ic|maildir}} if needed, also make sure the path is correct.<br />
<br />
To activate the new action, add this before the existing "match" line:<br />
<br />
match account ''bar'' action ''bar-deliver''<br />
<br />
Then all mail to {{ic|''bar@gmail.com''}} will be put into the {{ic|''bar-mail''}} mail folder.<br />
<br />
=== Automation ===<br />
<br />
Since ''fdm'' does not run as a daemon, timed mail fetching is left to job schedulers like [[cron]] or [[Systemd/Timers|systemd timers]].<br />
This section will show implementations for both.<br />
<br />
==== Cron ====<br />
<br />
Fetch and sort mail from all accounts every 15 minutes, appending a log all matches to a local file:<br />
{{hc|$ crontab -e|<br />
...<br />
*/15 * * * * fdm fetch >> $HOME/[Mm]ail/fdm.log<br />
}}<br />
<br />
==== systemd timer ====<br />
<br />
Setup the fdm service for the local user to fetch and sort mail from all accounts:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.service|<nowiki><br />
[Unit]<br />
<br />
Description=Fetch mail using fdm<br />
After=network.target network-online.target dbus.socket<br />
Documentation=man:fdm(1)<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/fdm fetch<br />
</nowiki>}}<br />
<br />
Then setup the timer to run the service every 15 minutes:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.timer|<nowiki><br />
[Unit]<br />
Description=Fetch mail using fdm<br />
<br />
[Timer]<br />
# Uncomment to run the service two minutes after booting<br />
# OnBootSec=2m<br />
OnUnitActiveSec=15m<br />
Persistent=true<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
</nowiki>}}<br />
<br />
Finally [[start/enable]] the user unit {{ic|fdm.timer}}.</div>Petrushttps://wiki.archlinux.org/index.php?title=Fdm&diff=733705Fdm2022-06-23T21:24:49Z<p>Petrus: link to AUR package</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Mail server]]<br />
[[Category:Mail retrieval agents]]<br />
[[es:Fdm]]<br />
[[ja:Fdm]]<br />
{{Related articles start}}<br />
{{Related|Mail server}}<br />
{{Related articles end}}<br />
[https://github.com/nicm/fdm fdm] (''fetch and deliver mail''), is a simple program for delivering and filtering mail. Comparing it to other same-purposed applications shows that it has similarities with [[Mutt]]'s very focused design principles.<br />
<br />
== Installing ==<br />
<br />
[[Install]] the {{Pkg|fdm}} package or the {{AUR|fdm-git}} package.<br />
<br />
== Configuration ==<br />
<br />
'''fdm''' can be configured trough a configuration file. <br />
Default is {{ic|~/.fdm.conf}}, or {{ic| /etc/fdm.conf}} if that does not exist.<br />
For full details refer to the manual pages {{man|1|fdm}}, {{man|5|fdm.conf}} and the<br />
{{ic|/usr/share/doc/fdm-git/MANUAL}}.<br />
<br />
=== mbox ===<br />
<br />
Alpine uses the mbox format, so we need to set up some files that we will be editing:<br />
$ cd<br />
$ mkdir mail<br />
$ touch mail/INBOX .fdm.conf <br />
$ chmod 600 .fdm.conf mail/INBOX<br />
<br />
=== maildir ===<br />
<br />
Mutt prefers a capitalized mail directory, and is able to use the maildir format. If you plan on using Mutt do the following setup:<br />
$ cd<br />
$ touch .fdm.conf; chmod 600 .fdm.conf<br />
$ mkdir -p Mail/INBOX/{new,cur,tmp}<br />
<br />
=== An example configuration ===<br />
<br />
Edit {{ic|.fdm.conf}}, and add your email accounts and basic filter rules. Use mbox or maildir, but not both.<br />
<br />
{{hc|.fdm.conf|<br />
## Accounts and rules for:<br />
#> foo@example.com<br />
#> bar@gmail.com<br />
## Last edit 21-Dec-09<br />
<br />
# Catch-all action (mbox):<br />
action "inbox" mbox "%h/mail/INBOX"<br />
# Catch-all action (maildir):<br />
# action "inbox" maildir "%h/Mail/INBOX"<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass "supersecret"<br />
<br />
account "bar" imaps server "imap.gmail.com"<br />
user "bar@gmail.com" pass "evenmoresecret"<br />
<br />
# Match all mail and deliver using the 'inbox' action.<br />
match all action "inbox"<br />
}}<br />
<br />
This will collect the mail from the listed accounts and deliver it to the INBOX folder that we made. Refer to the {{man|1|fdm}} man page for specifics on how to connect to other types of mail servers (POP3 for example).<br />
<br />
{{Tip|You can also specify your login name and/or password in the {{ic|.netrc}} file.}}<br />
<br />
== Password Management ==<br />
<br />
Passwords for email accounts can be stored as plain text in the config file or<br />
can be requested from a password manager or key-ring via a shell command, in the<br />
format of {{ic|$(cmd ...)}}<br />
<br />
=== Using a password manager ===<br />
<br />
Here is an example using '''pass''':<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass $(pass foo-email-entry | head -1)<br />
<br />
=== OAuth2 authentication, gmail ===<br />
<br />
While fdm can use OAuth2 access tokens in particular, it can be used with '''gmail''', it lacks the ability to renew and/or authorize OAuth2 credentials. A comprehensive solution is using the [https://github.com/pdobsan/mailctl mailctl] utility which provides IMAP/SMTP clients with the capabilities of renewal and authorization of OAuth2 credentials.<br />
<br />
Example config:<br />
<br />
account "foo" imaps server "imap.gmail.com"<br />
user "foo@gmail.com"<br />
pass $(mailctl access foo@gmail.com)<br />
oauthbearer<br />
<br />
A binary package is available from AUR: {{AUR| mailctl-bin}}<br />
<br />
=== Running from cron ===<br />
<br />
While the above examples work fine for interactive use, using them from a cron job is<br />
a bit more involved since some of the programs invoked might expect certain environments.<br />
One can work around that by using wrapper scripts and exporting the needed environment variables<br />
Here are a few tricks for such scripts:<br />
<br />
...<br />
# for pass<br />
export PASSWORD_STORE_DIR=~/.local/var/password-store<br />
...<br />
# when using gnome's keyring<br />
# secret-tool can't live without these two envvars<br />
# so we fake them for the case this script runs in a cron job<br />
export DISPLAY=${DISPLAY:-:0}<br />
export DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-unix:path=/run/user/$UID/bus}<br />
...<br />
<br />
== Testing ==<br />
<br />
Once you have this setup to your satisfaction, attempt to collect your mail by manually running fdm.<br />
$ fdm -kv fetch<br />
<br />
This will keep your mail untouched on the server incase there are errors. Look over the output to make sure everything worked as planned. Open your favorite mail reader (MUA) and make sure that you can read the mail that was just delivered.<br />
<br />
== Extended usage ==<br />
<br />
=== Additional filtering ===<br />
<br />
If you want to have mail from a certain account go to a specific mailbox, you could add the following lines to your {{ic|fdm.conf}} file. From the configuration file above, if you wanted to filter the mail from {{ic|''bar@gmail.com''}} into its own folder {{ic|''bar-mail''}}, you would add this below the existing "action" line:<br />
<br />
action ''bar-deliver'' mbox "%h/mail/''bar-mail''"<br />
<br />
Change the {{ic|mbox}} to {{ic|maildir}} if needed, also make sure the path is correct.<br />
<br />
To activate the new action, add this before the existing "match" line:<br />
<br />
match account ''bar'' action ''bar-deliver''<br />
<br />
Then all mail to {{ic|''bar@gmail.com''}} will be put into the {{ic|''bar-mail''}} mail folder.<br />
<br />
=== Automation ===<br />
<br />
Since ''fdm'' does not run as a daemon, timed mail fetching is left to job schedulers like [[cron]] or [[Systemd/Timers|systemd timers]].<br />
This section will show implementations for both.<br />
<br />
==== Cron ====<br />
<br />
Fetch and sort mail from all accounts every 15 minutes, appending a log all matches to a local file:<br />
{{hc|$ crontab -e|<br />
...<br />
*/15 * * * * fdm fetch >> $HOME/[Mm]ail/fdm.log<br />
}}<br />
<br />
==== systemd timer ====<br />
<br />
Setup the fdm service for the local user to fetch and sort mail from all accounts:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.service|<nowiki><br />
[Unit]<br />
<br />
Description=Fetch mail using fdm<br />
After=network.target network-online.target dbus.socket<br />
Documentation=man:fdm(1)<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/fdm fetch<br />
</nowiki>}}<br />
<br />
Then setup the timer to run the service every 15 minutes:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.timer|<nowiki><br />
[Unit]<br />
Description=Fetch mail using fdm<br />
<br />
[Timer]<br />
# Uncomment to run the service two minutes after booting<br />
# OnBootSec=2m<br />
OnUnitActiveSec=15m<br />
Persistent=true<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
</nowiki>}}<br />
<br />
Finally [[start/enable]] the user unit {{ic|fdm.timer}}.</div>Petrushttps://wiki.archlinux.org/index.php?title=Fdm&diff=733704Fdm2022-06-23T21:22:06Z<p>Petrus: comprehensive Oauth2 solution</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Mail server]]<br />
[[Category:Mail retrieval agents]]<br />
[[es:Fdm]]<br />
[[ja:Fdm]]<br />
{{Related articles start}}<br />
{{Related|Mail server}}<br />
{{Related articles end}}<br />
[https://github.com/nicm/fdm fdm] (''fetch and deliver mail''), is a simple program for delivering and filtering mail. Comparing it to other same-purposed applications shows that it has similarities with [[Mutt]]'s very focused design principles.<br />
<br />
== Installing ==<br />
<br />
[[Install]] the {{Pkg|fdm}} package or the {{AUR|fdm-git}} package.<br />
<br />
== Configuration ==<br />
<br />
'''fdm''' can be configured trough a configuration file. <br />
Default is {{ic|~/.fdm.conf}}, or {{ic| /etc/fdm.conf}} if that does not exist.<br />
For full details refer to the manual pages {{man|1|fdm}}, {{man|5|fdm.conf}} and the<br />
{{ic|/usr/share/doc/fdm-git/MANUAL}}.<br />
<br />
=== mbox ===<br />
<br />
Alpine uses the mbox format, so we need to set up some files that we will be editing:<br />
$ cd<br />
$ mkdir mail<br />
$ touch mail/INBOX .fdm.conf <br />
$ chmod 600 .fdm.conf mail/INBOX<br />
<br />
=== maildir ===<br />
<br />
Mutt prefers a capitalized mail directory, and is able to use the maildir format. If you plan on using Mutt do the following setup:<br />
$ cd<br />
$ touch .fdm.conf; chmod 600 .fdm.conf<br />
$ mkdir -p Mail/INBOX/{new,cur,tmp}<br />
<br />
=== An example configuration ===<br />
<br />
Edit {{ic|.fdm.conf}}, and add your email accounts and basic filter rules. Use mbox or maildir, but not both.<br />
<br />
{{hc|.fdm.conf|<br />
## Accounts and rules for:<br />
#> foo@example.com<br />
#> bar@gmail.com<br />
## Last edit 21-Dec-09<br />
<br />
# Catch-all action (mbox):<br />
action "inbox" mbox "%h/mail/INBOX"<br />
# Catch-all action (maildir):<br />
# action "inbox" maildir "%h/Mail/INBOX"<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass "supersecret"<br />
<br />
account "bar" imaps server "imap.gmail.com"<br />
user "bar@gmail.com" pass "evenmoresecret"<br />
<br />
# Match all mail and deliver using the 'inbox' action.<br />
match all action "inbox"<br />
}}<br />
<br />
This will collect the mail from the listed accounts and deliver it to the INBOX folder that we made. Refer to the {{man|1|fdm}} man page for specifics on how to connect to other types of mail servers (POP3 for example).<br />
<br />
{{Tip|You can also specify your login name and/or password in the {{ic|.netrc}} file.}}<br />
<br />
== Password Management ==<br />
<br />
Passwords for email accounts can be stored as plain text in the config file or<br />
can be requested from a password manager or key-ring via a shell command, in the<br />
format of {{ic|$(cmd ...)}}<br />
<br />
=== Using a password manager ===<br />
<br />
Here is an example using '''pass''':<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass $(pass foo-email-entry | head -1)<br />
<br />
=== OAuth2 authentication, gmail ===<br />
<br />
While fdm can use OAuth2 access tokens in particular, it can be used with '''gmail''', it lacks the ability to renew and/or authorize OAuth2 credentials. A comprehensive solution is using the [https://github.com/pdobsan/mailctl mailctl] utility which provides IMAP/SMTP clients with the capabilities of renewal and authorization of OAuth2 credentials.<br />
<br />
Example config:<br />
<br />
account "foo" imaps server "imap.gmail.com"<br />
user "foo@gmail.com"<br />
pass $(mailctl access foo@gmail.com)<br />
oauthbearer<br />
<br />
A binary package is available from AUR.<br />
<br />
=== Running from cron ===<br />
<br />
While the above examples work fine for interactive use, using them from a cron job is<br />
a bit more involved since some of the programs invoked might expect certain environments.<br />
One can work around that by using wrapper scripts and exporting the needed environment variables<br />
Here are a few tricks for such scripts:<br />
<br />
...<br />
# for pass<br />
export PASSWORD_STORE_DIR=~/.local/var/password-store<br />
...<br />
# when using gnome's keyring<br />
# secret-tool can't live without these two envvars<br />
# so we fake them for the case this script runs in a cron job<br />
export DISPLAY=${DISPLAY:-:0}<br />
export DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-unix:path=/run/user/$UID/bus}<br />
...<br />
<br />
== Testing ==<br />
<br />
Once you have this setup to your satisfaction, attempt to collect your mail by manually running fdm.<br />
$ fdm -kv fetch<br />
<br />
This will keep your mail untouched on the server incase there are errors. Look over the output to make sure everything worked as planned. Open your favorite mail reader (MUA) and make sure that you can read the mail that was just delivered.<br />
<br />
== Extended usage ==<br />
<br />
=== Additional filtering ===<br />
<br />
If you want to have mail from a certain account go to a specific mailbox, you could add the following lines to your {{ic|fdm.conf}} file. From the configuration file above, if you wanted to filter the mail from {{ic|''bar@gmail.com''}} into its own folder {{ic|''bar-mail''}}, you would add this below the existing "action" line:<br />
<br />
action ''bar-deliver'' mbox "%h/mail/''bar-mail''"<br />
<br />
Change the {{ic|mbox}} to {{ic|maildir}} if needed, also make sure the path is correct.<br />
<br />
To activate the new action, add this before the existing "match" line:<br />
<br />
match account ''bar'' action ''bar-deliver''<br />
<br />
Then all mail to {{ic|''bar@gmail.com''}} will be put into the {{ic|''bar-mail''}} mail folder.<br />
<br />
=== Automation ===<br />
<br />
Since ''fdm'' does not run as a daemon, timed mail fetching is left to job schedulers like [[cron]] or [[Systemd/Timers|systemd timers]].<br />
This section will show implementations for both.<br />
<br />
==== Cron ====<br />
<br />
Fetch and sort mail from all accounts every 15 minutes, appending a log all matches to a local file:<br />
{{hc|$ crontab -e|<br />
...<br />
*/15 * * * * fdm fetch >> $HOME/[Mm]ail/fdm.log<br />
}}<br />
<br />
==== systemd timer ====<br />
<br />
Setup the fdm service for the local user to fetch and sort mail from all accounts:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.service|<nowiki><br />
[Unit]<br />
<br />
Description=Fetch mail using fdm<br />
After=network.target network-online.target dbus.socket<br />
Documentation=man:fdm(1)<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/fdm fetch<br />
</nowiki>}}<br />
<br />
Then setup the timer to run the service every 15 minutes:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.timer|<nowiki><br />
[Unit]<br />
Description=Fetch mail using fdm<br />
<br />
[Timer]<br />
# Uncomment to run the service two minutes after booting<br />
# OnBootSec=2m<br />
OnUnitActiveSec=15m<br />
Persistent=true<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
</nowiki>}}<br />
<br />
Finally [[start/enable]] the user unit {{ic|fdm.timer}}.</div>Petrushttps://wiki.archlinux.org/index.php?title=Fdm&diff=732737Fdm2022-06-15T10:51:39Z<p>Petrus: community/fdm supports OAuth2</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Mail server]]<br />
[[Category:Mail retrieval agents]]<br />
[[es:Fdm]]<br />
[[ja:Fdm]]<br />
{{Related articles start}}<br />
{{Related|Mail server}}<br />
{{Related articles end}}<br />
[https://github.com/nicm/fdm fdm] (''fetch and deliver mail''), is a simple program for delivering and filtering mail. Comparing it to other same-purposed applications shows that it has similarities with [[Mutt]]'s very focused design principles.<br />
<br />
== Installing ==<br />
<br />
[[Install]] the {{Pkg|fdm}} package or the {{AUR|fdm-git}} package.<br />
<br />
== Configuration ==<br />
<br />
'''fdm''' can be configured trough a configuration file. <br />
Default is {{ic|~/.fdm.conf}}, or {{ic| /etc/fdm.conf}} if that does not exist.<br />
For full details refer to the manual pages {{man|1|fdm}}, {{man|5|fdm.conf}} and the<br />
{{ic|/usr/share/doc/fdm-git/MANUAL}}.<br />
<br />
=== mbox ===<br />
<br />
Alpine uses the mbox format, so we need to set up some files that we will be editing:<br />
$ cd<br />
$ mkdir mail<br />
$ touch mail/INBOX .fdm.conf <br />
$ chmod 600 .fdm.conf mail/INBOX<br />
<br />
=== maildir ===<br />
<br />
Mutt prefers a capitalized mail directory, and is able to use the maildir format. If you plan on using Mutt do the following setup:<br />
$ cd<br />
$ touch .fdm.conf; chmod 600 .fdm.conf<br />
$ mkdir -p Mail/INBOX/{new,cur,tmp}<br />
<br />
=== An example configuration ===<br />
<br />
Edit {{ic|.fdm.conf}}, and add your email accounts and basic filter rules. Use mbox or maildir, but not both.<br />
<br />
<br />
## .fdm.conf<br />
## Accounts and rules for:<br />
#> foo@example.com<br />
#> bar@gmail.com<br />
## Last edit 21-Dec-09<br />
<br />
# Catch-all action (mbox):<br />
action "inbox" mbox "%h/mail/INBOX"<br />
# Catch-all action (maildir):<br />
# action "inbox" maildir "%h/Mail/INBOX"<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass "supersecret"<br />
<br />
account "bar" imaps server "imap.gmail.com"<br />
user "bar@gmail.com" pass "evenmoresecret"<br />
<br />
# Match all mail and deliver using the 'inbox' action.<br />
match all action "inbox"<br />
<br />
This will collect the mail from the listed accounts and deliver it to the INBOX folder that we made. Refer to the {{man|1|fdm}} man page for specifics on how to connect to other types of mail servers (POP3 for example).<br />
<br />
{{Tip|You can also specify your login name and/or password in the {{ic|.netrc}} file.}}<br />
<br />
== Password Management ==<br />
<br />
Passwords for email accounts can be stored as plain text in the config file or<br />
can be requested from a password manager or key-ring via a shell command, in the<br />
format of {{ic|$(cmd ...)}}<br />
<br />
=== Using a password manager ===<br />
<br />
Here is an example using '''pass''':<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com"<br />
pass $(pass foo-email-entry | head -1)<br />
<br />
=== OAuth2 authentication, gmail ===<br />
<br />
Fdm now supports OAuth2, in particular, it can be used with '''gmail'''.<br />
<br />
Example config:<br />
<br />
account "foo" imaps server "imap.gmail.com"<br />
user "foo@gmail.com"<br />
pass $(get-token.sh foo@gmail.com)<br />
oauthbearer<br />
<br />
where {{ic|get-token.sh}} is a suitable wrapper script around Google's outh2.py script. The original is python2, but you can find a python3 version in [https://gist.github.com/fishy/bfdc3daa694e56e49cf9f06d4e67e807].<br />
<br />
You can find more details and links to various scripts in [[Msmtp#OAuth2_authentication_for_Gmail]].<br />
<br />
=== Running from cron ===<br />
<br />
While the above examples work fine for interactive use, using them from a cron job is<br />
a bit more involved since some of the programs invoked might expect certain environments.<br />
One can work around that by using wrapper scripts and exporting the needed environment variables<br />
Here are a few tricks for such scripts:<br />
<br />
...<br />
# for pass<br />
export PASSWORD_STORE_DIR=~/.local/var/password-store<br />
...<br />
# when using gnome's keyring<br />
# secret-tool can't live without these two envvars<br />
# so we fake them for the case this script runs in a cron job<br />
export DISPLAY=${DISPLAY:-:0}<br />
export DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-unix:path=/run/user/$UID/bus}<br />
...<br />
<br />
== Testing ==<br />
<br />
Once you have this setup to your satisfaction, attempt to collect your mail by manually running fdm.<br />
$ fdm -kv fetch<br />
<br />
This will keep your mail untouched on the server incase there are errors. Look over the output to make sure everything worked as planned. Open your favorite mail reader (MUA) and make sure that you can read the mail that was just delivered.<br />
<br />
== Extended usage ==<br />
<br />
=== Additional filtering ===<br />
<br />
If you want to have mail from a certain account go to a specific mailbox, you could add the following lines to your {{ic|fdm.conf}} file. From the configuration file above, if you wanted to filter the mail from {{ic|''bar@gmail.com''}} into its own folder {{ic|''bar-mail''}}, you would add this below the existing "action" line:<br />
<br />
action ''bar-deliver'' mbox "%h/mail/''bar-mail''"<br />
<br />
Change the {{ic|mbox}} to {{ic|maildir}} if needed, also make sure the path is correct.<br />
<br />
To activate the new action, add this before the existing "match" line:<br />
<br />
match account ''bar'' action ''bar-deliver''<br />
<br />
Then all mail to {{ic|''bar@gmail.com''}} will be put into the {{ic|''bar-mail''}} mail folder.<br />
<br />
=== Automation ===<br />
<br />
Since ''fdm'' does not run as a daemon, timed mail fetching is left to job schedulers like [[cron]] or [[Systemd/Timers|systemd timers]].<br />
This section will show implementations for both.<br />
<br />
==== Cron ====<br />
<br />
Fetch and sort mail from all accounts every 15 minutes, appending a log all matches to a local file:<br />
{{hc|$ crontab -e|<br />
...<br />
*/15 * * * * fdm fetch >> $HOME/[Mm]ail/fdm.log<br />
}}<br />
<br />
==== systemd timer ====<br />
<br />
Setup the fdm service for the local user to fetch and sort mail from all accounts:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.service|<nowiki><br />
[Unit]<br />
<br />
Description=Fetch mail using fdm<br />
After=network.target network-online.target dbus.socket<br />
Documentation=man:fdm(1)<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/fdm fetch<br />
</nowiki>}}<br />
<br />
Then setup the timer to run the service every 15 minutes:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.timer|<nowiki><br />
[Unit]<br />
Description=Fetch mail using fdm<br />
<br />
[Timer]<br />
# Uncomment to run the service two minutes after booting<br />
# OnBootSec=2m<br />
OnUnitActiveSec=15m<br />
Persistent=true<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
</nowiki>}}<br />
<br />
Finally [[start/enable]] the user unit {{ic|fdm.timer}}.</div>Petrushttps://wiki.archlinux.org/index.php?title=Fdm&diff=723988Fdm2022-03-22T20:15:53Z<p>Petrus: /* OAuth2 authentication, gmail */ fixed typos</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Mail server]]<br />
[[Category:Mail retrieval agents]]<br />
[[es:Fdm]]<br />
[[ja:Fdm]]<br />
{{Related articles start}}<br />
{{Related|Mail server}}<br />
{{Related articles end}}<br />
[https://github.com/nicm/fdm fdm] (''fetch and deliver mail''), is a simple program for delivering and filtering mail. Comparing it to other same-purposed applications shows that it has similarities with [[Mutt]]'s very focused design principles.<br />
<br />
== Installing ==<br />
<br />
[[Install]] the {{Pkg|fdm}} package or the {{AUR|fdm-git}} package.<br />
<br />
== Configuration ==<br />
<br />
<br />
'''fdm''' can be configured trough a configuration file. <br />
Default is {{ic|~/.fdm.conf}}, or {{ic| /etc/fdm.conf}} if that doesn't exist.<br />
For full details refer to the manual pages {{man|1|fdm}}, {{man|5|fdm.conf}} and the<br />
{{ic|/usr/share/doc/fdm-git/MANUAL}}.<br />
<br />
=== mbox ===<br />
<br />
Alpine uses the mbox format, so we need to set up some files that we will be editing:<br />
$ cd<br />
$ mkdir mail<br />
$ touch mail/INBOX .fdm.conf <br />
$ chmod 600 .fdm.conf mail/INBOX<br />
<br />
=== maildir ===<br />
<br />
Mutt prefers a capitized mail directory, and is able to use the maildir format. If you plan on using Mutt do the following setup:<br />
$ cd<br />
$ touch .fdm.conf; chmod 600 .fdm.conf<br />
$ mkdir -p Mail/INBOX/{new,cur,tmp}<br />
<br />
=== An example configuration ===<br />
<br />
Edit {{ic|.fdm.conf}}, and add your email accounts and basic filter rules. Use mbox or maildir, but not both.<br />
<br />
<br />
## .fdm.conf<br />
## Accounts and rules for:<br />
#> foo@example.com<br />
#> bar@gmail.com<br />
## Last edit 21-Dec-09<br />
<br />
# Catch-all action (mbox):<br />
action "inbox" mbox "%h/mail/INBOX"<br />
# Catch-all action (maildir):<br />
# action "inbox" maildir "%h/Mail/INBOX"<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass "supersecret"<br />
<br />
account "bar" imaps server "imap.gmail.com"<br />
user "bar@gmail.com" pass "evenmoresecret"<br />
<br />
# Match all mail and deliver using the 'inbox' action.<br />
match all action "inbox"<br />
<br />
This will collect the mail from the listed accounts and deliver it to the INBOX folder that we made. Refer to the {{man|1|fdm}} man page for specifics on how to connect to other types of mail servers (POP3 for example).<br />
<br />
{{Tip|You can also specify your login name and/or password in the {{ic|.netrc}} file.}}<br />
<br />
== Password Management ==<br />
<br />
Passwords for email accounts can be stored as plain text in the config file or<br />
can be requested from a password manager or key-ring via a shell command, in the<br />
format of {{ic|$(cmd ...)}}<br />
<br />
=== Using a password manager ===<br />
<br />
Here is an example using '''pass''':<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass $(pass foo-email-entry | head -1)<br />
<br />
=== OAuth2 authentication, gmail ===<br />
<br />
You need {{AUR|fdm-git}} to support Oauth2, in particular, it can be used with '''gmail'''.<br />
<br />
Example config:<br />
<br />
account "foo" imaps server "imap.gmail.com"<br />
user "foo@gmail.com"<br />
pass $(get-token.sh foo@gmail.com)<br />
oauthbearer<br />
<br />
where {{ic|get-token.sh}} is a suitable wrapper script around Google's outh2.py script.<br />
The original is python2, but you can find a python3 version here [https://gist.github.com/fishy/bfdc3daa694e56e49cf9f06d4e67e807 outh2.py for Python 3]<br />
<br />
You can find more details and links to various scripts in the [[https://wiki.archlinux.org/title/Msmtp#OAuth2_authentication_for_Gmail msmpt Arch wiki page]]<br />
<br />
=== Running from cron ===<br />
<br />
While the above examples work fine for interactive use, using them from a cron job is<br />
a bit more involved since some of the programs invoked might expect certain environments.<br />
One can work around that by using wrapper scripts and exporting the needed environment variables<br />
Here are a few tricks for such scripts:<br />
<br />
...<br />
# for pass<br />
export PASSWORD_STORE_DIR=~/.local/var/password-store<br />
...<br />
# when using gnome's keyring<br />
# secret-tool can't live without these two envvars<br />
# so we fake them for the case this script runs in a cron job<br />
export DISPLAY=${DISPLAY:-:0}<br />
export DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-unix:path=/run/user/$UID/bus}<br />
...<br />
<br />
== Testing ==<br />
<br />
Once you have this setup to your satisfaction, attempt to collect your mail by manually running fdm.<br />
$ fdm -kv fetch<br />
<br />
This will keep your mail untouched on the server incase there are errors. Look over the output to make sure everything worked as planned. Open your favorite mail reader (MUA) and make sure that you can read the mail that was just delivered.<br />
<br />
== Extended usage ==<br />
<br />
=== Additional filtering ===<br />
<br />
If you want to have mail from a certain account go to a specific mailbox, you could add the following lines to your {{ic|fdm.conf}} file. From the configuration file above, if you wanted to filter the mail from {{ic|''bar@gmail.com''}} into its own folder {{ic|''bar-mail''}}, you would add this below the existing "action" line:<br />
<br />
action ''bar-deliver'' mbox "%h/mail/''bar-mail''"<br />
<br />
Change the {{ic|mbox}} to {{ic|maildir}} if needed, also make sure the path is correct.<br />
<br />
To activate the new action, add this before the existing "match" line:<br />
<br />
match account ''bar'' action ''bar-deliver''<br />
<br />
Then all mail to {{ic|''bar@gmail.com''}} will be put into the {{ic|''bar-mail''}} mail folder.<br />
<br />
=== Automation ===<br />
<br />
Since ''fdm'' does not run as a daemon, timed mail fetching is left to job schedulers like [[cron]] or [[Systemd/Timers|systemd timers]].<br />
This section will show implementations for both.<br />
<br />
==== Cron ====<br />
<br />
Fetch and sort mail from all accounts every 15 minutes, appending a log all matches to a local file:<br />
{{hc|$ crontab -e|<br />
...<br />
*/15 * * * * fdm fetch >> $HOME/[Mm]ail/fdm.log<br />
}}<br />
<br />
==== systemd timer ====<br />
<br />
Setup the fdm service for the local user to fetch and sort mail from all accounts:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.service|<nowiki><br />
[Unit]<br />
<br />
Description=Fetch mail using fdm<br />
After=network.target network-online.target dbus.socket<br />
Documentation=man:fdm(1)<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/fdm fetch<br />
</nowiki>}}<br />
<br />
Then setup the timer to run the service every 15 minutes:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.timer|<nowiki><br />
[Unit]<br />
Description=Fetch mail using fdm<br />
<br />
[Timer]<br />
# Uncomment to run the service two minutes after booting<br />
# OnBootSec=2m<br />
OnUnitActiveSec=15m<br />
Persistent=true<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
</nowiki>}}<br />
<br />
Finally [[start/enable]] the user unit {{ic|fdm.timer}}.</div>Petrushttps://wiki.archlinux.org/index.php?title=Fdm&diff=723983Fdm2022-03-22T18:09:36Z<p>Petrus: /* OAuth2 authentication, gmail */ link aur</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Mail server]]<br />
[[Category:Mail retrieval agents]]<br />
[[es:Fdm]]<br />
[[ja:Fdm]]<br />
{{Related articles start}}<br />
{{Related|Mail server}}<br />
{{Related articles end}}<br />
[https://github.com/nicm/fdm fdm] (''fetch and deliver mail''), is a simple program for delivering and filtering mail. Comparing it to other same-purposed applications shows that it has similarities with [[Mutt]]'s very focused design principles.<br />
<br />
= Installing =<br />
<br />
[[Install]] the {{Pkg|fdm}} package or the {{AUR|fdm-git}} package.<br />
<br />
= Configuration =<br />
<br />
<br />
'''fdm''' can be configured trough a configuration file. <br />
Default is {{ic|~/.fdm.conf}}, or {{ic| /etc/fdm.conf}} if that doesn't exist.<br />
For full details refer to the manual pages {{man|1|fdm}}, {{man|5|fdm.conf}} and the<br />
{{ic|/usr/share/doc/fdm-git/MANUAL}}.<br />
<br />
=== mbox ===<br />
<br />
Alpine uses the mbox format, so we need to set up some files that we will be editing:<br />
$ cd<br />
$ mkdir mail<br />
$ touch mail/INBOX .fdm.conf <br />
$ chmod 600 .fdm.conf mail/INBOX<br />
<br />
=== maildir ===<br />
<br />
Mutt prefers a capitized mail directory, and is able to use the maildir format. If you plan on using Mutt do the following setup:<br />
$ cd<br />
$ touch .fdm.conf; chmod 600 .fdm.conf<br />
$ mkdir -p Mail/INBOX/{new,cur,tmp}<br />
<br />
=== An example configuration ===<br />
<br />
Edit {{ic|.fdm.conf}}, and add your email accounts and basic filter rules. Use mbox or maildir, but not both.<br />
<br />
<br />
## .fdm.conf<br />
## Accounts and rules for:<br />
#> foo@example.com<br />
#> bar@gmail.com<br />
## Last edit 21-Dec-09<br />
<br />
# Catch-all action (mbox):<br />
action "inbox" mbox "%h/mail/INBOX"<br />
# Catch-all action (maildir):<br />
# action "inbox" maildir "%h/Mail/INBOX"<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass "supersecret"<br />
<br />
account "bar" imaps server "imap.gmail.com"<br />
user "bar@gmail.com" pass "evenmoresecret"<br />
<br />
# Match all mail and deliver using the 'inbox' action.<br />
match all action "inbox"<br />
<br />
This will collect the mail from the listed accounts and deliver it to the INBOX folder that we made. Refer to the {{man|1|fdm}} man page for specifics on how to connect to other types of mail servers (POP3 for example).<br />
<br />
{{Tip|You can also specify your login name and/or password in the {{ic|.netrc}} file.}}<br />
<br />
== Password Management ==<br />
<br />
Passwords for email accounts can be stored as plain text in the config file or<br />
can be requested from a password manager or key-ring via a shell command, in the<br />
format of {{ic|$(cmd ...)}}<br />
<br />
=== Using a password manager ===<br />
<br />
Here is an example using '''pass''':<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass $(pass foo-email-entry | head -1)<br />
<br />
=== OAuth2 authentication, gmail ===<br />
<br />
You need {{AUR|fdm-git}} to support Oauth2, in particular, it can be used with '''gmail'''.<br />
<br />
Example config:<br />
<br />
account "foo" imaps server "imap.gmail.com"<br />
user "foo@egmail.com"<br />
pass $(get-token.sh foo@egmail.com)<br />
oauthbearer<br />
<br />
where {{ic|get-token.sh}} is a suitable wrapper script around Google's outh2.py script.<br />
The original is python2, but you can find a python3 version here [https://gist.github.com/fishy/bfdc3daa694e56e49cf9f06d4e67e807 outh2.py for Python 3]<br />
<br />
You can find more details and links to various scripts in the [[https://wiki.archlinux.org/title/Msmtp#OAuth2_authentication_for_Gmail msmpt wiki page]]<br />
<br />
=== Running from cron ===<br />
<br />
While the above examples work fine for interactive use, using them from a cron job is<br />
a bit more involved since some of the programs invoked might expect certain environments.<br />
One can work around that by using wrapper scripts and exporting the needed environment variables<br />
Here are a few tricks for such scripts:<br />
<br />
...<br />
# for pass<br />
export PASSWORD_STORE_DIR=~/.local/var/password-store<br />
...<br />
# when using gnome's keyring<br />
# secret-tool can't live without these two envvars<br />
# so we fake them for the case this script runs in a cron job<br />
export DISPLAY=${DISPLAY:-:0}<br />
export DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-unix:path=/run/user/$UID/bus}<br />
...<br />
<br />
== Testing ==<br />
<br />
Once you have this setup to your satisfaction, attempt to collect your mail by manually running fdm.<br />
$ fdm -kv fetch<br />
<br />
This will keep your mail untouched on the server incase there are errors. Look over the output to make sure everything worked as planned. Open your favorite mail reader (MUA) and make sure that you can read the mail that was just delivered.<br />
<br />
== Extended usage ==<br />
<br />
=== Additional filtering ===<br />
<br />
If you want to have mail from a certain account go to a specific mailbox, you could add the following lines to your {{ic|fdm.conf}} file. From the configuration file above, if you wanted to filter the mail from {{ic|''bar@gmail.com''}} into its own folder {{ic|''bar-mail''}}, you would add this below the existing "action" line:<br />
<br />
action ''bar-deliver'' mbox "%h/mail/''bar-mail''"<br />
<br />
Change the {{ic|mbox}} to {{ic|maildir}} if needed, also make sure the path is correct.<br />
<br />
To activate the new action, add this before the existing "match" line:<br />
<br />
match account ''bar'' action ''bar-deliver''<br />
<br />
Then all mail to {{ic|''bar@gmail.com''}} will be put into the {{ic|''bar-mail''}} mail folder.<br />
<br />
=== Automation ===<br />
<br />
Since ''fdm'' does not run as a daemon, timed mail fetching is left to job schedulers like [[cron]] or [[Systemd/Timers|systemd timers]].<br />
This section will show implementations for both.<br />
<br />
==== Cron ====<br />
<br />
Fetch and sort mail from all accounts every 15 minutes, appending a log all matches to a local file:<br />
{{hc|$ crontab -e|<br />
...<br />
*/15 * * * * fdm fetch >> $HOME/[Mm]ail/fdm.log<br />
}}<br />
<br />
==== systemd timer ====<br />
<br />
Setup the fdm service for the local user to fetch and sort mail from all accounts:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.service|<nowiki><br />
[Unit]<br />
<br />
Description=Fetch mail using fdm<br />
After=network.target network-online.target dbus.socket<br />
Documentation=man:fdm(1)<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/fdm fetch<br />
</nowiki>}}<br />
<br />
Then setup the timer to run the service every 15 minutes:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.timer|<nowiki><br />
[Unit]<br />
Description=Fetch mail using fdm<br />
<br />
[Timer]<br />
# Uncomment to run the service two minutes after booting<br />
# OnBootSec=2m<br />
OnUnitActiveSec=15m<br />
Persistent=true<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
</nowiki>}}<br />
<br />
Finally [[start/enable]] the user unit {{ic|fdm.timer}}.</div>Petrushttps://wiki.archlinux.org/index.php?title=Fdm&diff=723981Fdm2022-03-22T18:07:48Z<p>Petrus: /* Installing */ restructure</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Mail server]]<br />
[[Category:Mail retrieval agents]]<br />
[[es:Fdm]]<br />
[[ja:Fdm]]<br />
{{Related articles start}}<br />
{{Related|Mail server}}<br />
{{Related articles end}}<br />
[https://github.com/nicm/fdm fdm] (''fetch and deliver mail''), is a simple program for delivering and filtering mail. Comparing it to other same-purposed applications shows that it has similarities with [[Mutt]]'s very focused design principles.<br />
<br />
= Installing =<br />
<br />
[[Install]] the {{Pkg|fdm}} package or the {{AUR|fdm-git}} package.<br />
<br />
= Configuration =<br />
<br />
<br />
'''fdm''' can be configured trough a configuration file. <br />
Default is {{ic|~/.fdm.conf}}, or {{ic| /etc/fdm.conf}} if that doesn't exist.<br />
For full details refer to the manual pages {{man|1|fdm}}, {{man|5|fdm.conf}} and the<br />
{{ic|/usr/share/doc/fdm-git/MANUAL}}.<br />
<br />
=== mbox ===<br />
<br />
Alpine uses the mbox format, so we need to set up some files that we will be editing:<br />
$ cd<br />
$ mkdir mail<br />
$ touch mail/INBOX .fdm.conf <br />
$ chmod 600 .fdm.conf mail/INBOX<br />
<br />
=== maildir ===<br />
<br />
Mutt prefers a capitized mail directory, and is able to use the maildir format. If you plan on using Mutt do the following setup:<br />
$ cd<br />
$ touch .fdm.conf; chmod 600 .fdm.conf<br />
$ mkdir -p Mail/INBOX/{new,cur,tmp}<br />
<br />
=== An example configuration ===<br />
<br />
Edit {{ic|.fdm.conf}}, and add your email accounts and basic filter rules. Use mbox or maildir, but not both.<br />
<br />
<br />
## .fdm.conf<br />
## Accounts and rules for:<br />
#> foo@example.com<br />
#> bar@gmail.com<br />
## Last edit 21-Dec-09<br />
<br />
# Catch-all action (mbox):<br />
action "inbox" mbox "%h/mail/INBOX"<br />
# Catch-all action (maildir):<br />
# action "inbox" maildir "%h/Mail/INBOX"<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass "supersecret"<br />
<br />
account "bar" imaps server "imap.gmail.com"<br />
user "bar@gmail.com" pass "evenmoresecret"<br />
<br />
# Match all mail and deliver using the 'inbox' action.<br />
match all action "inbox"<br />
<br />
This will collect the mail from the listed accounts and deliver it to the INBOX folder that we made. Refer to the {{man|1|fdm}} man page for specifics on how to connect to other types of mail servers (POP3 for example).<br />
<br />
{{Tip|You can also specify your login name and/or password in the {{ic|.netrc}} file.}}<br />
<br />
== Password Management ==<br />
<br />
Passwords for email accounts can be stored as plain text in the config file or<br />
can be requested from a password manager or key-ring via a shell command, in the<br />
format of {{ic|$(cmd ...)}}<br />
<br />
=== Using a password manager ===<br />
<br />
Here is an example using '''pass''':<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass $(pass foo-email-entry | head -1)<br />
<br />
=== OAuth2 authentication, gmail ===<br />
<br />
'''fdm-git''' now supports Oauth2, in particular, it can be used with '''gmail'''.<br />
<br />
Example config:<br />
<br />
account "foo" imaps server "imap.gmail.com"<br />
user "foo@egmail.com"<br />
pass $(get-token.sh foo@egmail.com)<br />
oauthbearer<br />
<br />
where {{ic|get-token.sh}} is a suitable wrapper script around Google's outh2.py script.<br />
The original is python2, but you can find a python3 version here [https://gist.github.com/fishy/bfdc3daa694e56e49cf9f06d4e67e807 outh2.py for Python 3]<br />
<br />
You can find more details and links to various scripts in the [[https://wiki.archlinux.org/title/Msmtp#OAuth2_authentication_for_Gmail msmpt wiki page]]<br />
<br />
=== Running from cron ===<br />
<br />
While the above examples work fine for interactive use, using them from a cron job is<br />
a bit more involved since some of the programs invoked might expect certain environments.<br />
One can work around that by using wrapper scripts and exporting the needed environment variables<br />
Here are a few tricks for such scripts:<br />
<br />
...<br />
# for pass<br />
export PASSWORD_STORE_DIR=~/.local/var/password-store<br />
...<br />
# when using gnome's keyring<br />
# secret-tool can't live without these two envvars<br />
# so we fake them for the case this script runs in a cron job<br />
export DISPLAY=${DISPLAY:-:0}<br />
export DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-unix:path=/run/user/$UID/bus}<br />
...<br />
<br />
== Testing ==<br />
<br />
Once you have this setup to your satisfaction, attempt to collect your mail by manually running fdm.<br />
$ fdm -kv fetch<br />
<br />
This will keep your mail untouched on the server incase there are errors. Look over the output to make sure everything worked as planned. Open your favorite mail reader (MUA) and make sure that you can read the mail that was just delivered.<br />
<br />
== Extended usage ==<br />
<br />
=== Additional filtering ===<br />
<br />
If you want to have mail from a certain account go to a specific mailbox, you could add the following lines to your {{ic|fdm.conf}} file. From the configuration file above, if you wanted to filter the mail from {{ic|''bar@gmail.com''}} into its own folder {{ic|''bar-mail''}}, you would add this below the existing "action" line:<br />
<br />
action ''bar-deliver'' mbox "%h/mail/''bar-mail''"<br />
<br />
Change the {{ic|mbox}} to {{ic|maildir}} if needed, also make sure the path is correct.<br />
<br />
To activate the new action, add this before the existing "match" line:<br />
<br />
match account ''bar'' action ''bar-deliver''<br />
<br />
Then all mail to {{ic|''bar@gmail.com''}} will be put into the {{ic|''bar-mail''}} mail folder.<br />
<br />
=== Automation ===<br />
<br />
Since ''fdm'' does not run as a daemon, timed mail fetching is left to job schedulers like [[cron]] or [[Systemd/Timers|systemd timers]].<br />
This section will show implementations for both.<br />
<br />
==== Cron ====<br />
<br />
Fetch and sort mail from all accounts every 15 minutes, appending a log all matches to a local file:<br />
{{hc|$ crontab -e|<br />
...<br />
*/15 * * * * fdm fetch >> $HOME/[Mm]ail/fdm.log<br />
}}<br />
<br />
==== systemd timer ====<br />
<br />
Setup the fdm service for the local user to fetch and sort mail from all accounts:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.service|<nowiki><br />
[Unit]<br />
<br />
Description=Fetch mail using fdm<br />
After=network.target network-online.target dbus.socket<br />
Documentation=man:fdm(1)<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/fdm fetch<br />
</nowiki>}}<br />
<br />
Then setup the timer to run the service every 15 minutes:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.timer|<nowiki><br />
[Unit]<br />
Description=Fetch mail using fdm<br />
<br />
[Timer]<br />
# Uncomment to run the service two minutes after booting<br />
# OnBootSec=2m<br />
OnUnitActiveSec=15m<br />
Persistent=true<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
</nowiki>}}<br />
<br />
Finally [[start/enable]] the user unit {{ic|fdm.timer}}.</div>Petrushttps://wiki.archlinux.org/index.php?title=Fdm&diff=723979Fdm2022-03-22T18:04:36Z<p>Petrus: /* Configuring */ adding password management and oauth2 stuff</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Mail server]]<br />
[[Category:Mail retrieval agents]]<br />
[[es:Fdm]]<br />
[[ja:Fdm]]<br />
{{Related articles start}}<br />
{{Related|Mail server}}<br />
{{Related articles end}}<br />
[https://github.com/nicm/fdm fdm] (''fetch and deliver mail''), is a simple program for delivering and filtering mail. Comparing it to other same-purposed applications shows that it has similarities with [[Mutt]]'s very focused design principles.<br />
<br />
== Installing ==<br />
<br />
[[Install]] the {{Pkg|fdm}} package or the {{AUR|fdm-git}} package.<br />
<br />
= Configuration =<br />
<br />
<br />
'''fdm''' can be configured trough a configuration file. <br />
Default is {{ic|~/.fdm.conf}}, or {{ic| /etc/fdm.conf}} if that doesn't exist.<br />
For full details refer to the manual pages {{man|1|fdm}}, {{man|5|fdm.conf}} and the<br />
{{ic|/usr/share/doc/fdm-git/MANUAL}}.<br />
<br />
=== mbox ===<br />
<br />
Alpine uses the mbox format, so we need to set up some files that we will be editing:<br />
$ cd<br />
$ mkdir mail<br />
$ touch mail/INBOX .fdm.conf <br />
$ chmod 600 .fdm.conf mail/INBOX<br />
<br />
=== maildir ===<br />
<br />
Mutt prefers a capitized mail directory, and is able to use the maildir format. If you plan on using Mutt do the following setup:<br />
$ cd<br />
$ touch .fdm.conf; chmod 600 .fdm.conf<br />
$ mkdir -p Mail/INBOX/{new,cur,tmp}<br />
<br />
=== An example configuration ===<br />
<br />
Edit {{ic|.fdm.conf}}, and add your email accounts and basic filter rules. Use mbox or maildir, but not both.<br />
<br />
<br />
## .fdm.conf<br />
## Accounts and rules for:<br />
#> foo@example.com<br />
#> bar@gmail.com<br />
## Last edit 21-Dec-09<br />
<br />
# Catch-all action (mbox):<br />
action "inbox" mbox "%h/mail/INBOX"<br />
# Catch-all action (maildir):<br />
# action "inbox" maildir "%h/Mail/INBOX"<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass "supersecret"<br />
<br />
account "bar" imaps server "imap.gmail.com"<br />
user "bar@gmail.com" pass "evenmoresecret"<br />
<br />
# Match all mail and deliver using the 'inbox' action.<br />
match all action "inbox"<br />
<br />
This will collect the mail from the listed accounts and deliver it to the INBOX folder that we made. Refer to the {{man|1|fdm}} man page for specifics on how to connect to other types of mail servers (POP3 for example).<br />
<br />
{{Tip|You can also specify your login name and/or password in the {{ic|.netrc}} file.}}<br />
<br />
== Password Management ==<br />
<br />
Passwords for email accounts can be stored as plain text in the config file or<br />
can be requested from a password manager or key-ring via a shell command, in the<br />
format of {{ic|$(cmd ...)}}<br />
<br />
=== Using a password manager ===<br />
<br />
Here is an example using '''pass''':<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass $(pass foo-email-entry | head -1)<br />
<br />
=== OAuth2 authentication, gmail ===<br />
<br />
'''fdm-git''' now supports Oauth2, in particular, it can be used with '''gmail'''.<br />
<br />
Example config:<br />
<br />
account "foo" imaps server "imap.gmail.com"<br />
user "foo@egmail.com"<br />
pass $(get-token.sh foo@egmail.com)<br />
oauthbearer<br />
<br />
where {{ic|get-token.sh}} is a suitable wrapper script around Google's outh2.py script.<br />
The original is python2, but you can find a python3 version here [https://gist.github.com/fishy/bfdc3daa694e56e49cf9f06d4e67e807 outh2.py for Python 3]<br />
<br />
You can find more details and links to various scripts in the [[https://wiki.archlinux.org/title/Msmtp#OAuth2_authentication_for_Gmail msmpt wiki page]]<br />
<br />
=== Running from cron ===<br />
<br />
While the above examples work fine for interactive use, using them from a cron job is<br />
a bit more involved since some of the programs invoked might expect certain environments.<br />
One can work around that by using wrapper scripts and exporting the needed environment variables<br />
Here are a few tricks for such scripts:<br />
<br />
...<br />
# for pass<br />
export PASSWORD_STORE_DIR=~/.local/var/password-store<br />
...<br />
# when using gnome's keyring<br />
# secret-tool can't live without these two envvars<br />
# so we fake them for the case this script runs in a cron job<br />
export DISPLAY=${DISPLAY:-:0}<br />
export DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-unix:path=/run/user/$UID/bus}<br />
...<br />
<br />
== Testing ==<br />
<br />
Once you have this setup to your satisfaction, attempt to collect your mail by manually running fdm.<br />
$ fdm -kv fetch<br />
<br />
This will keep your mail untouched on the server incase there are errors. Look over the output to make sure everything worked as planned. Open your favorite mail reader (MUA) and make sure that you can read the mail that was just delivered.<br />
<br />
== Extended usage ==<br />
<br />
=== Additional filtering ===<br />
<br />
If you want to have mail from a certain account go to a specific mailbox, you could add the following lines to your {{ic|fdm.conf}} file. From the configuration file above, if you wanted to filter the mail from {{ic|''bar@gmail.com''}} into its own folder {{ic|''bar-mail''}}, you would add this below the existing "action" line:<br />
<br />
action ''bar-deliver'' mbox "%h/mail/''bar-mail''"<br />
<br />
Change the {{ic|mbox}} to {{ic|maildir}} if needed, also make sure the path is correct.<br />
<br />
To activate the new action, add this before the existing "match" line:<br />
<br />
match account ''bar'' action ''bar-deliver''<br />
<br />
Then all mail to {{ic|''bar@gmail.com''}} will be put into the {{ic|''bar-mail''}} mail folder.<br />
<br />
=== Automation ===<br />
<br />
Since ''fdm'' does not run as a daemon, timed mail fetching is left to job schedulers like [[cron]] or [[Systemd/Timers|systemd timers]].<br />
This section will show implementations for both.<br />
<br />
==== Cron ====<br />
<br />
Fetch and sort mail from all accounts every 15 minutes, appending a log all matches to a local file:<br />
{{hc|$ crontab -e|<br />
...<br />
*/15 * * * * fdm fetch >> $HOME/[Mm]ail/fdm.log<br />
}}<br />
<br />
==== systemd timer ====<br />
<br />
Setup the fdm service for the local user to fetch and sort mail from all accounts:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.service|<nowiki><br />
[Unit]<br />
<br />
Description=Fetch mail using fdm<br />
After=network.target network-online.target dbus.socket<br />
Documentation=man:fdm(1)<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/fdm fetch<br />
</nowiki>}}<br />
<br />
Then setup the timer to run the service every 15 minutes:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.timer|<nowiki><br />
[Unit]<br />
Description=Fetch mail using fdm<br />
<br />
[Timer]<br />
# Uncomment to run the service two minutes after booting<br />
# OnBootSec=2m<br />
OnUnitActiveSec=15m<br />
Persistent=true<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
</nowiki>}}<br />
<br />
Finally [[start/enable]] the user unit {{ic|fdm.timer}}.</div>Petrushttps://wiki.archlinux.org/index.php?title=Fdm&diff=723973Fdm2022-03-22T16:09:19Z<p>Petrus: fdm-git is available from AUR</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Mail server]]<br />
[[Category:Mail retrieval agents]]<br />
[[es:Fdm]]<br />
[[ja:Fdm]]<br />
{{Related articles start}}<br />
{{Related|Mail server}}<br />
{{Related articles end}}<br />
[https://github.com/nicm/fdm fdm] (''fetch and deliver mail''), is a simple program for delivering and filtering mail. Comparing it to other same-purposed applications shows that it has similarities with [[Mutt]]'s very focused design principles.<br />
<br />
== Installing ==<br />
<br />
[[Install]] the {{Pkg|fdm}} package or the {{AUR|fdm-git}} package.<br />
<br />
== Configuring ==<br />
<br />
''fdm'' supports the tried and tested mbox format along with the newer maildir specification.<br />
<br />
=== mbox ===<br />
<br />
Alpine uses the mbox format, so we need to set up some files that we will be editing:<br />
$ cd<br />
$ mkdir mail<br />
$ touch mail/INBOX .fdm.conf <br />
$ chmod 600 .fdm.conf mail/INBOX<br />
<br />
=== maildir ===<br />
<br />
Mutt prefers a capitized mail directory, and is able to use the maildir format. If you plan on using Mutt do the following setup:<br />
$ cd<br />
$ touch .fdm.conf; chmod 600 .fdm.conf<br />
$ mkdir -p Mail/INBOX/{new,cur,tmp}<br />
<br />
=== Final setup ===<br />
<br />
Edit {{ic|.fdm.conf}}, and add your email accounts and basic filter rules. Use mbox or maildir, but not both.<br />
## .fdm.conf<br />
## Accounts and rules for:<br />
#> foo@example.com<br />
#> bar@gmail.com<br />
## Last edit 21-Dec-09<br />
<br />
# Catch-all action (mbox):<br />
action "inbox" mbox "%h/mail/INBOX"<br />
# Catch-all action (maildir):<br />
# action "inbox" maildir "%h/Mail/INBOX"<br />
<br />
account "foo" imaps server "imap.example.com"<br />
user "foo@example.com" pass "supersecret"<br />
<br />
account "bar" imaps server "imap.gmail.com"<br />
user "bar@gmail.com" pass "evenmoresecret"<br />
<br />
# Match all mail and deliver using the 'inbox' action.<br />
match all action "inbox"<br />
<br />
This will collect the mail from the listed accounts and deliver it to the INBOX folder that we made. Refer to the {{man|1|fdm}} man page for specifics on how to connect to other types of mail servers (POP3 for example).<br />
<br />
{{Tip|You can also specify your login name and/or password in the {{ic|.netrc}} file.}}<br />
<br />
== Testing ==<br />
<br />
Once you have this setup to your satisfaction, attempt to collect your mail by manually running fdm.<br />
$ fdm -kv fetch<br />
<br />
This will keep your mail untouched on the server incase there are errors. Look over the output to make sure everything worked as planned. Open your favorite mail reader (MUA) and make sure that you can read the mail that was just delivered.<br />
<br />
== Extended usage ==<br />
<br />
=== Additional filtering ===<br />
<br />
If you want to have mail from a certain account go to a specific mailbox, you could add the following lines to your {{ic|fdm.conf}} file. From the configuration file above, if you wanted to filter the mail from {{ic|''bar@gmail.com''}} into its own folder {{ic|''bar-mail''}}, you would add this below the existing "action" line:<br />
<br />
action ''bar-deliver'' mbox "%h/mail/''bar-mail''"<br />
<br />
Change the {{ic|mbox}} to {{ic|maildir}} if needed, also make sure the path is correct.<br />
<br />
To activate the new action, add this before the existing "match" line:<br />
<br />
match account ''bar'' action ''bar-deliver''<br />
<br />
Then all mail to {{ic|''bar@gmail.com''}} will be put into the {{ic|''bar-mail''}} mail folder.<br />
<br />
=== Automation ===<br />
<br />
Since ''fdm'' does not run as a daemon, timed mail fetching is left to job schedulers like [[cron]] or [[Systemd/Timers|systemd timers]].<br />
This section will show implementations for both.<br />
<br />
==== Cron ====<br />
<br />
Fetch and sort mail from all accounts every 15 minutes, appending a log all matches to a local file:<br />
{{hc|$ crontab -e|<br />
...<br />
*/15 * * * * fdm fetch >> $HOME/[Mm]ail/fdm.log<br />
}}<br />
<br />
==== systemd timer ====<br />
<br />
Setup the fdm service for the local user to fetch and sort mail from all accounts:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.service|<nowiki><br />
[Unit]<br />
<br />
Description=Fetch mail using fdm<br />
After=network.target network-online.target dbus.socket<br />
Documentation=man:fdm(1)<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/fdm fetch<br />
</nowiki>}}<br />
<br />
Then setup the timer to run the service every 15 minutes:<br />
{{hc|${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/fdm.timer|<nowiki><br />
[Unit]<br />
Description=Fetch mail using fdm<br />
<br />
[Timer]<br />
# Uncomment to run the service two minutes after booting<br />
# OnBootSec=2m<br />
OnUnitActiveSec=15m<br />
Persistent=true<br />
<br />
[Install]<br />
WantedBy=timers.target<br />
</nowiki>}}<br />
<br />
Finally [[start/enable]] the user unit {{ic|fdm.timer}}.</div>Petrushttps://wiki.archlinux.org/index.php?title=Arch_Linux_on_a_VPS&diff=468152Arch Linux on a VPS2017-02-11T16:08:36Z<p>Petrus: updated linode's arch template's date, it was out of date</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[Category:Virtualization]]<br />
[[ja:Virtual Private Server]]<br />
[[zh-hans:Virtual Private Server]]<br />
{{Related articles start}}<br />
{{Related|Server}}<br />
{{Related articles end}}<br />
From [[Wikipedia:Virtual private server]]:<br />
<br />
:Virtual private server (VPS) is a term used by Internet hosting services to refer to a virtual machine. The term is used for emphasizing that the virtual machine, although running in software on the same physical computer as other customers' virtual machines, is in many respects functionally equivalent to a separate physical computer, is dedicated to the individual customer's needs, has the privacy of a separate physical computer, and can be configured to run server software.<br />
<br />
This article discusses the use of Arch Linux on Virtual Private Servers, and includes some fixes and installation instructions specific to VPSes.<br />
<br />
{{Warning|<br />
* Linux 2.6.32 is not supported by systemd since version 205 (and will not work with systemd-212 or higher). Since many container-based virtualization environments rely on older kernels, it may be impossible to keep an Arch Linux install up-to-date in such an environment. However, OpenVZ, as of [http://openvz.org/Download/kernel/rhel6/042stab094.7 kernel build 042stab094.7], has backported the CLOCK_BOOTTIME feature, making it work with later versions of systemd.<br />
* Systemd since version 220 doesn't work on OpenVZ containers. [https://github.com/systemd/systemd/issues/421] This issue has been fixed in OpenVZ kernel 042stab111.1 [https://bugzilla.openvz.org/show_bug.cgi?id&#x3D;3280#c11]}}<br />
<br />
==Providers that offer Arch Linux==<br />
<br />
{{Warning|We cannot vouch for the honesty or quality of any provider. Please conduct due diligence before ordering.}}<br />
{{Note|This list is for providers with a convenient Arch Linux template. Using Arch on other providers is possible but requires more work. Example methods include: <br />
* Loading custom disc images (requires hardware virtualization such as in Xen or KVM), <br />
* [[Installation guide|Installing under chroot]], for example with the help of the [https://github.com/drizzt/vps2arch vps2arch] script (it will download the latest iso; be particularly aware of the systemd 220/221 [https://github.com/systemd/systemd/issues/421 bug]), or <br />
* Following [[#Installing the latest Arch Linux on any OpenVZ provider]] instructions, using rsync to synchronize Arch over the top of another distribution.}}<br />
<br />
{| class="wikitable"<br />
! Provider !! Arch Release !! Virtualization !! Locations !! Notes<br />
|-<br />
| [http://www.4smart.cz/ 4smart.cz] || 2013.08 || OpenVZ || Prague, CZ || (Czech language site only) when updating system make sure you use [tredaelli-systemd] in pacman.conf (see [[Unofficial user repositories]]<br />
|-<br />
| [https://www.affinity.net.nz/ affinity.net.nz] || 2013.08.01 || KVM || Auckland, New Zealand (NZ) || IRC channel is #affinity on ircs.kiwicon.org<br />
|-<br />
| [https://www.atlantic.net/ Atlantic.Net] || 2015.05.01 || KVM || NYC/SF/Toronto/Dallas/Orlando, US & Canada || 100% SSD 1-click Arch Linux, ready in 30 seconds<br />
|-<br />
| [http://www.buyvm.net/ BuyVM] || 2013.07.01 || KVM || LA, Buffalo NY || Must chose a different OS at sign up. Once accessible, choose to mount the latest Arch ISO and reboot to install manually. <br />
|-<br />
| [https://coinshost.com/en/vps Coinshost] || 2015.04 || Xen || Zurich, Switzerland || Bitcoin and other cryptocurrencies accepted.<br />
|-<br />
| [https://www.directvps.nl/ DirectVPS] || 2014.01.xx || OpenVZ || Amsterdam, NL; Rotterdam, NL || (Dutch language site only)<br />
|-<br />
| [http://www.edis.at/en/ Edis] || [http://www.edis.at/en/support-and-service/faq/server-faq/which-distributions-are-available-with-edis-kvm-vps-plans/ 2013.03.01] || vServer, KVM, OpenVZ || [http://www.edis.at/en/server/kvm-vps/austria/ Multiple international locations]. || Also offer dedicated server options as well as an "off-shore" location at the Isle of Man (IM).<br />
|-<br />
| [https://www.gigatux.com/virtual.php GigaTux] || [https://www.gigatux.com/distro/ 2013.06.01] || Xen || Chicago, US-IL; Frankfurt, DE; London, GB; San Jose, US-CA ||<br />
|-<br />
| [https://www.hostvirtual.com/ Host Virtual] || [https://www.hostvirtual.com/os/linux-vps/archlinux-vps 2014.06.01] || KVM || [http://www.vr.org/cloud-locations/ Multiple International Locations] || Appears to use KVM virtualization. Site lists "Xen based virtualization" and [http://www.vr.org/features/ features] lists ability to install from ISO.<br />
|-<br />
| [https://hostigation.com/ Hostigation] || [https://hostigation.com/wiki/index.php?title=KVM:Install 2010.05 i686] || OpenVZ, KVM || Charlotte, US-NC; Los Angeles, US-CA || You can [[Migrating Between Architectures Without Reinstalling|migrate to x86_64]].<br />
|-<br />
| [https://www.kloud51.com Kloud51] || Latest || OpenVZ || US-CA, Canada || SSD, 2 images available: A bare-bones system or a pre-configured Desktop with OpenBox, XRDP, Firefox, Fail2ban, Geany, and Yaourt.<br />
|-<br />
| [https://leapswitch.com Leapswitch Networks] || 2013.10.xx || OpenVZ/KVM || USA, India, Portugal, Spain, Ukraine, Germany || Arch Linux currently available in Control Panel for reinstall, not on order form. <br />
|-<br />
| [https://linevast.de Linevast.de] || Latest || OpenVZ, KVM || Germany || Arch Linux is possible on openvz and on KVM with the one click os installer. <br />
|-<br />
| [https://www.linode.com Linode.com] || [https://blog.linode.com/2016/06/13/arch-linux-network-configuration-update/ 2016.06.01] || Xen, KVM || [https://www.linode.com/speedtest/ Tokyo, JP; Multiple US; London, GB] || To run a custom kernel, install {{AUR|linux-linode}} ({{pkg|linux}} will break on a 32-bit Linode). When shipped, the NIC enp4s0 is renamed to eth0 and reverts back to enp4s0 on reboot --- on reboot, this may cause sshd load to fail.<br />
|-<br />
| [http://lylix.net/ LYLIX] || [http://lylix.net/archlinux 2014.01.xx] || OpenVZ || Multiple US; Europe || 32-bit and 64-bit available <br />
|-<br />
| [https://www.nodedeploy.com/ Node Deploy] || 2014.10.01 || OpenVZ, KVM || Germany (DE); Los Angeles, US-CA; Atlanta, US-GA; Phoenix, US-AZ || "At NodeDeploy we support virtually every linux distribution." Arch Linux is listed under their Operating Systems. No version information.<br />
|-<br />
| [https://www.netcup.de/ Netcup] || 2012.11.xx || KVM || Germany (DE)|| (German language site only)<br />
|-<br />
| [https://www.onepoundwebhosting.co.uk/ OnePoundWebHosting] || 2014.01 || Xen PV, Xen HVM || United Kingdom (UK) || They are a registrar too. Unable to verify server locations.<br />
|-<br />
| [https://www.ovh.com/us/vps/ OVH] || Latest || KVM || France, Canada ||<br />
|-<br />
| [https://www.pacmanvps.com/ PacmanVPS] || [https://panel.pacmanvps.com/machines/new Latest] || KVM || Canada (CA), Poland (PL) || Support for any kernel. Ready to use template or install manually from ISO in VNC console.<br />
|-<br />
| [https://www.proplay.de/ Proplay] || Latest || OpenVZ, KVM || Germany (DE) || (German language site only)<br />
|-<br />
| [https://www.rackspace.com/cloud/servers Rackspace Cloud] || 2013.6 || Xen || [https://www.rackspace.com/whyrackspace/network/datacenters/ Multiple international locations] || Billed per hour. Use their "next gen" VPSes (using the mycloud.rackspace.com panel); the Arch image on the first gen Rackspace VPSes is out of date.<br />
|-<br />
| [http://www.ramhost.us/ RamHost.us] || [http://www.ramhost.us/?page=news 2013.05.01] || OpenVZ, KVM || Los Angeles, US-CA; Great Britain (GB); Atlanta, US-GA; Germany (DE) || You can request a newer ISO on RamHost's IRC network.<br />
|-<br />
| [http://www.ramnode.com/ RamNode] || [https://clientarea.ramnode.com/knowledgebase.php?action=displayarticle&id=48 2016.01.01] || [https://clientarea.ramnode.com/knowledgebase.php?action=displayarticle&id=39 SSD and SSD Cached:] [https://clientarea.ramnode.com/knowledgebase.php?action=displayarticle&id=52 KVM] || [https://clientarea.ramnode.com/knowledgebase.php?action=displayarticle&id=50 Alblasserdam, NL; Atlanta, GA-US; Los Angeles, CA-US; New York, NY-US; Seattle, WA-US] || You can request Host/CPU passthrough with KVM service.[https://clientarea.ramnode.com/knowledgebase.php?action=displayarticle&id=66] Frequent use of discount promotions.[https://twitter.com/search?q=ramnode%20code&src=typd], Must install Arch manually from an ISO using VNC viewer.<br />
|-<br />
| [https://www.rosehosting.com/ RoseHosting] || Latest || OpenVZ, KVM || St. Louis, Missouri, USA || SSD powered hosting plans with free fully-managed 24/7 support <br />
|-<br />
| [https://www.tilaa.com/ Tilaa] || 2016.03.01 || [https://www.tilaa.com/pages/vps/technology KVM] || Amsterdam, NL ||<br />
|-<br />
| [https://www.transip.eu/ TransIP] || [https://www.transip.eu/vps/vps-os/ 2017.01.01] || [https://www.transip.eu/vps/vps-technology/ KVM] || Amsterdam, NL || Also registrar.<br />
|-<br />
| [https://upcube.io upCUBE] || Latest || Docker || Germany || Different prepared arch linux templates available<br />
|-<br />
| [http://www.xenvz.co.uk/ XenVZ] || 2009.12.07 || OpenVZ, Xen || United Kingdom (UK), United States (US) || [http://www.xenvz.co.uk/faq.php#use2 Hardware]<br />
|-<br />
| [http://virpus.com/ Virpus] || [http://virpus.com/linux-vps.php 2014.11.07] || Xen || Kansas City, US-KS; Los Angeles, US-CA || A subcompany of Wow Technologies, Inc. 24/7 support via Live Chat, Email, Phone, and Ticket System.<br />
|-<br />
| [https://www.virtualmaster.com/ Virtual Master] || 2012-08 || ?? || Prague, CZ ||<br />
|-<br />
| [http://www.vmline.pl/ VMLine] || 2013.09.01 || KVM, OpenVZ || Kraków, PL || (Polish language site only) [http://www.s-net.pl/en/ S-Net] reseller. Full virtualization.<br />
|-<br />
| [https://www.vpsbg.eu/ VPSBG.eu] || 2013.10 || OpenVZ || [https://vpsbg.eu/en/index.php?page=vps-datacenter Sofia, Bulgaria] || Offshore VPS in Bulgaria - anonymous registrations and Bitcoin are accepted.<br />
|-<br />
| [https://vps6.net/ VPS6.NET] || 2013.01.xx || OpenVZ, Xen, HVM-ISO || [http://vps6.net/network/ Multiple US]; Frankfurt, DE; Bucharest, RO; Istanbul, TR || Registrar.<br />
|- <br />
| [http://www.world4you.com/ World4You] || 2015.10.28 || OpenVZ || Austria (AT) || Internet hosting provider; quick setup; 24/7 support; shared web hosting; also CentOS, Debian, Ubuntu, Fedora and Arch OpenVZ servers; supports newest systemd (227 atm)<br />
|-<br />
|}<br />
<br />
==Installation==<br />
<br />
===KVM===<br />
{{Expansion|Are there instructions specific to VPSes?}}<br />
See [[QEMU#Preparing an (Arch) Linux guest]].<br />
<br />
===OpenVZ===<br />
<br />
====Installing the latest Arch Linux on any OpenVZ provider====<br />
<br />
{{Warning|See the [[#top|above warning]] about older kernel builds and systemd.}}<br />
<br />
It is possible to directly copy an installation of Arch Linux over the top of a working OpenVZ VPS. This tutorial explains how to create a basic installation of Arch Linux with {{ic|pacstrap}} (as used in a standard install) and then replace the contents of a target VPS with it using [[rsync]].<br />
<br />
This process (with minor modification) also works to migrate existing Arch installations between various environments and has been confirmed to work in migrating from OpenVZ to Xen and from Xen to OpenVZ. For an install to Xen, other hardware-virtualized platforms, or probably even to physical hardware (unconfirmed), extra steps (basically running {{ic|mkinitcpio}} and [[Boot loaders|installing a bootloader]]) are needed.<br />
<br />
=====Prerequisites=====<br />
<br />
* A working Arch Linux installation<br />
** To keep things simple, it should match the architecture you want to install on your VPS (x86_64 or i686).<br />
** To build from other distributions, [[Archbootstrap|arch-bootstrap.sh]] can be used in place of {{ic|pacstrap}}.<br />
* The {{Pkg|arch-install-scripts}}, {{Pkg|rsync}}, and {{Pkg|openssh}} packages from the [[official repositories]]<br />
** SSH is not strictly required, but rsync over SSH is the method used here.<br />
* A VPS running any distribution, with {{ic|rsync}} and a working SSH server<br />
** Its architecture (x86_64 or i686) does not matter as long as the OpenVZ installation can support your target architecture.<br />
* OpenVZ's serial console feature (usually accessible via your provider's control panel)<br />
** Without this, any network configuration for the target VPS will have to be done immediately after the "Build" step below.<br />
<br />
=====Building a clean Arch Linux installation=====<br />
<br />
As root, build the installation (optionally replacing {{ic|build}} with your preferred target directory):<br />
<br />
# mkdir build<br />
# pacstrap -cd build<br />
<br />
Other tweaks for the {{ic|pacstrap}} command:<br />
<br />
*{{ic|-C custom-pacman-config.conf}} - Use a custom pacman configuration file. By default, {{ic|pacstrap}} builds according to your local pacman.conf. This determines the architecture (i686 or x86_64) of the build, the mirror list, etc.<br />
*{{ic|-G}} - Prevent {{ic|pacstrap}} from copying your system's pacman keyring to the new build. If you use this option, you will need to run {{ic|pacman-key --init}} and {{ic|pacman-key --populate archlinux}} in the [[#Configuration|Configuration]] step to set up the keyring.<br />
*{{ic|-M}} - Prevent {{ic|pacstrap}} from copying your system's pacman mirror list to the new build.<br />
*You can pass a list of packages to {{ic|pacstrap}} to add them to your install, instead of the default {{ic|base}} group. For example: {{ic|pacstrap -cd build base openssh dnsutils gnu-netcat traceroute vim}}<br />
<br />
=====Replacing everything on the VPS with the Arch build=====<br />
<br />
Replace all files, directories, etc. on your target VPS with the contents of your {{ic|build}} directory (replacing "YOUR.VPS.IP.ADDRESS" below):<br />
<br />
{{Warning|Be careful with the following command. By design, {{ic|rsync}} is very destructive, especially with any of the {{ic|--delete}} options.}}<br />
<br />
# rsync -axH --delete-delay -e ssh --stats -P build/ YOUR.VPS.IP.ADDRESS:/<br />
<br />
Explanation of options:<br />
<br />
* {{ic|-a}} - Required. Preserves timestamps, permissions, etc.<br />
* {{ic|--delete}} - Required. Deletes anything in the target that does not exist in the source<br />
* {{ic|-x}} - Important. Prevents the crossing of filesystem boundaries (other partitions, /dev, etc.) during the copy<br />
* {{ic|-H}} - Important. Preserves hardlinks<br />
* {{ic|--delete-delay}} - Recommended. Enables alternate deletion mode which waits to delete anything until the synchronization is otherwise complete, which may reduce the risk of a slow transfer causing the target VPS to lock-up<br />
* {{ic|-e ssh}} - Recommended. Uses {{ic|rsync}} over SSH (recommended for simplicity compared to setting up an {{ic|rsync}} server)<br />
* {{ic|-P}} - Recommended. Shows partial progress information during transfer<br />
* {{ic|--stats}} - Recommended. Shows transfer statistics at the end<br />
<br />
=====Configuration=====<br />
<br />
# Reboot the VPS externally (using your provider's control panel, for example).<br />
# Using OpenVZ's serial console feature, configure the [[network]] and [[Installation_guide#Configure_the_system|basic system settings]] (ignoring fstab generation and arch-chroot steps).<br />
#* If you do not have access to the serial console feature, you will need to preconfigure your network settings before synchronizing Arch to the VPS.<br />
#* On some VPS configuration you won't have a gateway to connect to, here is an example [[netctl]] configuration for this setup. It configures static IP addresses and default routes on venet0 and uses Google Public DNS.<br />
{{hc|/etc/netctl/venet|2=<br />
Description='VPS venet connection'<br />
Interface=venet0<br />
Connection=ethernet<br />
<br />
IP=static<br />
Address=('192.0.2.42/32')<br />
Routes=('default')<br />
<br />
IP6=static<br />
Address6=('2001:db8::1234:5678/128')<br />
Routes6=('default')<br />
<br />
DNS=('2001:4860:4860::8888' '2001:4860:4860::8844' '8.8.8.8' '8.8.4.4')<br />
}}<br />
<br />
===Xen===<br />
{{Expansion|Are there instructions specific to VPSes?}}<br />
See [[Xen#Arch as Xen guest (PVHVM mode)]]{{Broken section link}} and/or [[Xen#Arch as Xen guest (PV mode)]]{{Broken section link}}.</div>Petrushttps://wiki.archlinux.org/index.php?title=Start_X_at_login&diff=263448Start X at login2013-06-19T10:07:18Z<p>Petrus: Minor corrections: better wording, structure.</p>
<hr />
<div>[[Category:X Server]]<br />
[[Category:Boot process]]<br />
[[es:Start X at Boot]]<br />
[[fr:Startx]]<br />
[[hu:Start X at Boot]]<br />
[[it:Start X at Boot]]<br />
[[ja:Start X at Login]]<br />
[[pt:Start X at Boot]]<br />
[[ru:Start X at Boot]]<br />
[[th:Start X at Boot]]<br />
[[zh-CN:Start X at Login]]<br />
{{Article summary start}}<br />
{{Article summary text|Starting X automatically at login to a virtual terminal.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|systemd/User}}<br />
{{Article summary wiki|Automatic login to virtual console}}<br />
{{Article summary wiki|Display Manager}}<br />
{{Article summary wiki|Silent boot}}<br />
{{Article summary wiki|Xinitrc}}<br />
{{Article summary end}}<br />
<br />
Usually, a [[Display Manager|display manager]] can be used to provide a login screen and start the [[X server]]. This article explains how to start X at a virtual terminal without using a display manager.<br />
<br />
== Start X manually at a virtual terminal ==<br />
<br />
To manually start X, {{ic|startx}} is used, which will execute {{ic|~/.xinitrc}}, which may be customized to start the window manager of choice as described in the [[xinitrc]] article.<br />
<br />
== Start X automatically when logging in at a virtual terminal ==<br />
<br />
{{Note|These solutions run X on the same tty used to login, which is required in order to maintain the login session.}}<br />
<br />
* For [[Bash]], add the following to the bottom of {{ic|~/.bash_profile}}. If the file does not exist, copy a skeleton version from {{ic|/etc/skel/.bash_profile}}.<br />
<br />
* For [[Zsh]], add it to {{ic|~/.zprofile}} instead.<br />
{{bc|1=<nowiki><br />
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx<br />
</nowiki>}}<br />
<br />
* For [[Fish]], add the following to the bottom of your {{ic|~/.config/fish/config.fish}}.<br />
{{bc|1=<nowiki><br />
# start X at login<br />
if status --is-login<br />
if test -z "$DISPLAY" -a $XDG_VTNR = 1<br />
exec startx<br />
end<br />
end<br />
</nowiki>}}<br />
<br />
{{Note|<br />
* You can replace the {{ic|-eq 1}} comparison with one like {{ic|-le 3}} (for vt1 to vt3) if you want to use graphical logins on more than one VT.<br />
* X must always be run on the same tty where the login occurred, to preserve the logind session. This is handled by the default {{ic|/etc/X11/xinit/xserverrc}}.<br />
}}<br />
<br />
== Tips ==<br />
<br />
* This method can be combined with [[automatic login to virtual console]]. When doing this you have to set correct dependencies for the autologin systemd service to ensure that dbus is started before {{ic|~/.xinitrc}} is read and hence pulseaudio started (see: [https://bbs.archlinux.org/viewtopic.php?id=155416 BBS#155416])<br />
* If you would like to remain logged in when the X session ends, remove {{ic|exec}}.<br />
* To redirect the output of the X session to a file, create an [[alias]]:<br />
: {{bc|1=alias startx='startx & > ~/.xlog'}}</div>Petrushttps://wiki.archlinux.org/index.php?title=Start_X_at_login&diff=263443Start X at login2013-06-19T09:57:32Z<p>Petrus: Added automatic start details for the fish shell.</p>
<hr />
<div>[[Category:X Server]]<br />
[[Category:Boot process]]<br />
[[es:Start X at Boot]]<br />
[[fr:Startx]]<br />
[[hu:Start X at Boot]]<br />
[[it:Start X at Boot]]<br />
[[ja:Start X at Login]]<br />
[[pt:Start X at Boot]]<br />
[[ru:Start X at Boot]]<br />
[[th:Start X at Boot]]<br />
[[zh-CN:Start X at Login]]<br />
{{Article summary start}}<br />
{{Article summary text|Starting X automatically at login to a virtual terminal.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|systemd/User}}<br />
{{Article summary wiki|Automatic login to virtual console}}<br />
{{Article summary wiki|Display Manager}}<br />
{{Article summary wiki|Silent boot}}<br />
{{Article summary wiki|Xinitrc}}<br />
{{Article summary end}}<br />
<br />
A [[Display Manager|display manager]] can be used to provide a login screen and start the [[X server]]. This article explains how this can be done using an existing virtual terminal.<br />
<br />
To manually start X, {{ic|startx}} is used, which will execute {{ic|~/.xinitrc}}, which may be customized to start the window manager of choice as described in the [[xinitrc]] article.<br />
<br />
== Start X automatically when logging in at a virtual terminal ==<br />
<br />
{{Note|These solutions run X on the same tty used to login, which is required in order to maintain the login session.}}<br />
<br />
* For [[Bash]], add the following to the bottom of {{ic|~/.bash_profile}}. If the file does not exist, copy a skeleton version from {{ic|/etc/skel/.bash_profile}}.<br />
<br />
* For [[Zsh]], add it to {{ic|~/.zprofile}} instead.<br />
{{bc|1=<nowiki><br />
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx<br />
</nowiki>}}<br />
<br />
* For [[Fish]], add the following to the bottom of your {{ic|~/.config/fish/config.fish}}.<br />
{{bc|1=<nowiki><br />
# start X at login<br />
if status --is-login<br />
if test -z "$DISPLAY" -a $XDG_VTNR = 1<br />
exec startx<br />
end<br />
end<br />
</nowiki>}}<br />
<br />
{{Note|<br />
* You can replace the {{ic|-eq 1}} comparison with one like {{ic|-le 3}} (for vt1 to vt3) if you want to use graphical logins on more than one VT.<br />
* X must always be run on the same tty where the login occurred, to preserve the logind session. This is handled by the default {{ic|/etc/X11/xinit/xserverrc}}.<br />
}}<br />
<br />
== Tips ==<br />
<br />
* This method can be combined with [[automatic login to virtual console]]. When doing this you have to set correct dependencies for the autologin systemd service to ensure that dbus is started before {{ic|~/.xinitrc}} is read and hence pulseaudio started (see: [https://bbs.archlinux.org/viewtopic.php?id=155416 BBS#155416])<br />
* If you would like to remain logged in when the X session ends, remove {{ic|exec}}.<br />
* To redirect the output of the X session to a file, create an [[alias]]:<br />
: {{bc|1=alias startx='startx & > ~/.xlog'}}</div>Petrus