{"id":29091171,"url":"https://github.com/cra3z/smtplib","last_synced_at":"2025-10-16T00:23:42.649Z","repository":{"id":300962360,"uuid":"1007160049","full_name":"Cra3z/smtplib","owner":"Cra3z","description":"A C++ SMTP client","archived":false,"fork":false,"pushed_at":"2025-06-24T12:21:56.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-24T13:34:27.065Z","etag":null,"topics":["cpp","smtp-client"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cra3z.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-23T14:53:07.000Z","updated_at":"2025-06-24T12:22:00.000Z","dependencies_parsed_at":"2025-06-24T13:35:54.979Z","dependency_job_id":"13fa05a9-2fbc-4a1f-95f7-19b2586d516f","html_url":"https://github.com/Cra3z/smtplib","commit_stats":null,"previous_names":["cra3z/smtplib"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Cra3z/smtplib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cra3z%2Fsmtplib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cra3z%2Fsmtplib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cra3z%2Fsmtplib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cra3z%2Fsmtplib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cra3z","download_url":"https://codeload.github.com/Cra3z/smtplib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cra3z%2Fsmtplib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262382732,"owners_count":23302296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","smtp-client"],"created_at":"2025-06-28T06:05:45.764Z","updated_at":"2025-10-16T00:23:42.578Z","avatar_url":"https://github.com/Cra3z.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"en | [zh-cn](README.zh-CN.md)\n# smtplib\n\nsmtplib is a simple SMTP mail sending library based on Asio, supporting both synchronous and coroutine-based asynchronous interfaces, and supports `SSL/TLS` and `STARTTLS`.\n\n# Build \u0026 Install\n\n```shell\ngit clone https://github.com/Cra3z/smtplib.git\ncd smtplib\nmkdir \u003cyour-build-dir\u003e\ncmake -S . -B \u003cyour-build-dir\u003e -DSMTPLIB_EXAMPLES=ON\ncmake --build \u003cyour-build-dir\u003e\ncmake --install \u003cyour-build-dir\u003e --prefix \u003cyour-install-dir\u003e\n```\nThe following two variables determine whether to use Boost.Asio or standalone Asio, and whether to use `std::format` or `fmt::format`:  \n* `SMTPLIB_USE_BOOST_ASIO`: Use Boost.Asio\n* `SMTPLIB_USE_FMT_FORMAT`: Use the fmt library for formatting\n\nFor example:  \n```shell\ncmake -S . -B \u003cyour-build-dir\u003e -DSMTPLIB_EXAMPLES=ON -DSMTPLIB_USE_BOOST_ASIO=ON -DSMTPLIB_USE_FMT_FORMAT=OFF\n```\nThis will use Boost.Asio and `std::format`.\n\nsmtplib is a header-only library, so you can simply copy `smtplib.h` to where you need it.  \nHowever, it is recommended to embed smtplib as a subproject in your project, or install it first and then import it via CMake's `find_package`.\n\n## Build Requirements\n\n* CMake \u003e= 3.26\n* C++17 or newer (C++20 is used by default)\n\n### Dependencies\n* [Boost.Asio](https://github.com/boostorg/asio) \u003e= 1.87 or [standalone Asio](https://github.com/chriskohlhoff/asio) \u003e= 1.28\n* [openssl](https://github.com/openssl/openssl) \u003e= 0.9.8\n* [fmt](https://github.com/fmtlib/fmt) \u003e= 10.1 (optional, not needed if `std::format` is available)\n\n# Examples\n\nSynchronous send with SSL:\n```cpp\nsmtplib::net::io_context io_context;\nsmtplib::client cli{\n    io_context.get_executor(),\n    \"your email\",\n    \"password\",\n    smtplib::security::ssl\n};\ncli.connect(\"smtp.example.com\", 465);\ncli.send({\n    .from = \"your email\",\n    .to = \"target email\",\n    .subject = \"Test\",\n    .body = \"Hello!\"\n});\n```\n\nAsynchronous send (C++20 coroutine) with STARTTLS:\n```cpp\nsmtplib::net::io_context io_context;\nsmtplib::client cli{\n    io_context.get_executor(),\n    \"your email\",\n    \"password\",\n    smtplib::security::starttls\n};\nsmtplib::net::co_spawn(\n    io_context,\n    [\u0026]() -\u003e smtplib::net::awaitable\u003cvoid\u003e {\n        co_await cli.async_connect(\"smtp.example.com\", 587);\n        co_await cli.async_send({\n            .from = \"your email\",\n            .to = \"target email\",\n            .subject = \"Test\",\n            .body = \"Hello!\"\n        });\n    },\n    [](std::exception_ptr exp) {\n        try {\n            if (exp) {\n                std::rethrow_exception(exp);\n            }\n        }\n        catch (const std::exception\u0026 ex) {\n            std::cerr \u003c\u003c \"[ERROR] \" \u003c\u003c ex.what() \u003c\u003c std::endl;\n        }\n    }\n);\nio_context.run();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcra3z%2Fsmtplib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcra3z%2Fsmtplib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcra3z%2Fsmtplib/lists"}