109 lines
4.5 KiB
HTML
109 lines
4.5 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>Interact iRedAdmin-Pro RESTful API with `curl`</title>
|
|
<link rel="stylesheet" type="text/css" href="./css/markdown.css" />
|
|
</head>
|
|
<body>
|
|
|
|
<div id="navigation">
|
|
<a href="/index.html" target="_blank">
|
|
<img alt="iRedMail web site"
|
|
src="./images/logo-iredmail.png"
|
|
style="vertical-align: middle; height: 30px;"
|
|
/>
|
|
<span>iRedMail</span>
|
|
</a>
|
|
// <a href="./index.html">Document Index</a></div><h1 id="interact-iredadmin-pro-restful-api-with-curl">Interact iRedAdmin-Pro RESTful API with <code>curl</code></h1>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">Note</p>
|
|
<ul>
|
|
<li>For more details about iRedAdmin-Pro RESTful API, please read document:
|
|
<a href="./iredadmin-pro.restful.api.html">iRedAdmin-Pro: RESTful API</a>.</li>
|
|
<li>If you need an API which has not yet been implemented, don't hesitate to
|
|
<a href="../contact.html">contact us</a>.</li>
|
|
<li>Our sample code below requires thiard-party Python module <code>requests</code>. For
|
|
more details, please read its official documentation:
|
|
<a href="http://docs.python-requests.org/en/master/">Requests: HTTP for Humans</a></li>
|
|
</ul>
|
|
</div>
|
|
<p>Sample <code>curl</code> commands to interact iRedAdmin-Pro RESTful API.</p>
|
|
<ul>
|
|
<li>replace <code><server></code> in url by the real server address (hostname or IP) which
|
|
runs iRedAdmin-Pro (with the <code>/iredadmin</code> prefix). for example,
|
|
<code>https://my_domain.com/iredadmin</code>.</li>
|
|
<li>replace <code><domain></code> in url by the real domain name.</li>
|
|
<li>replace <code><mail></code> in url by the real email address.</li>
|
|
</ul>
|
|
<pre><code>#
|
|
# Login
|
|
#
|
|
# Replace `<username>` by the real admin email address.
|
|
# Replace `<password>` by the real admin password.
|
|
# It will create a plain text file `cookie.txt` under current directory.
|
|
curl -X POST -c cookie.txt -d "username=<username>&password=<password>" https://<server>/api/login
|
|
|
|
#
|
|
# Create domain (POST)
|
|
#
|
|
# cn=ABC Inc. (display name: "ABC Inc."
|
|
# quota=20480 (quota: 20 GB)
|
|
curl -X POST -i -b cookie.txt -d "cn=ABC Inc.&quota=20480" https://<server>/api/domain/<domain>
|
|
|
|
#
|
|
# Create mail user (POST)
|
|
#
|
|
# cn=Zhang Huangbin (display name: "Zhang Huangbin")
|
|
# mailQuota=1024 (mailbox quota: 1 GB)
|
|
curl -X POST -i -b cookie.txt -d "cn=Zhang Huangbin&mailQuota=1024" https://<server>/api/user/<mail>
|
|
|
|
#
|
|
# Delete mail user (DELETE)
|
|
#
|
|
curl -X DELETE -i -b cookie.txt https://<server>/api/user/<mail>
|
|
|
|
#
|
|
# Update mail user profiles (PUT)
|
|
#
|
|
curl -X PUT -i -b cookie.txt -d "cn=John Smith&mailQuota=2048" https://<server>/api/user/<mail>
|
|
|
|
#
|
|
# Create mail alias (POST)
|
|
#
|
|
# cn=My Alias (display name: "My Alias")
|
|
curl -X POST -i -b cookie.txt -d "cn=My Alias" https://<server>/api/alias/<mail>
|
|
|
|
#
|
|
# Delete mail alias (DELETE)
|
|
#
|
|
curl -X DELETE -i -b cookie.txt https://<server>/api/alias/<mail>
|
|
|
|
#
|
|
# Create mailing list (POST, OpenLDAP backend only)
|
|
#
|
|
curl -X POST -i -b cookie.txt -d "cn=My List" https://<server>/api/maillist/<mail>
|
|
|
|
#
|
|
# Delete mail alias (DELETE)
|
|
#
|
|
curl -X DELETE -i -b cookie.txt https://<server>/api/maillist/<mail>
|
|
|
|
#
|
|
# Delete domain (DELETE)
|
|
#
|
|
curl -X DELETE -i -b cookie.txt https://<server>/api/domain/<domain>
|
|
</code></pre>
|
|
|
|
<h2 id="see-also">See Also</h2>
|
|
<ul>
|
|
<li><a href="./iredadmin-pro.restful.api.python.html">Interact iRedAdmin-Pro RESTful API with Python</a></li>
|
|
</ul><p style="text-align: center; color: grey;">All documents are available in <a href="https://bitbucket.org/zhb/iredmail-docs/src">BitBucket repository</a>, and published under <a href="http://creativecommons.org/licenses/by-nd/3.0/us/" target="_blank">Creative Commons</a> license. If you found something wrong, please do <a href="http://www.iredmail.org/contact.html">contact us</a> to fix it.<script>
|
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
|
|
ga('create', 'UA-3293801-21', 'auto');
|
|
ga('send', 'pageview');
|
|
</script>
|
|
</body></html> |