You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Windows上编译带SMTP支持的CURL?解决SMTP协议不支持报错

Fixing "Protocol 'smtp' not supported or disabled in libcurl" When Building Curl for Windows (No SSL/SSH)

Let's break down exactly how to compile curl with SMTP support (alongside basic file download protocols like HTTP) without including SSL or SSH. The error you're seeing means your current build didn't enable SMTP support—even if you used Visual Studio, the default settings probably didn't flip that critical switch.

Step 1: Grab the Latest Curl Source Code

First, download the full curl source code and extract it to a folder on your machine (e.g., C:\curl-source). Pre-built binaries won't work here since we need a customized build.

Step 2: Configure the Build for SMTP (No SSL/SSH)

Curl has a dedicated Windows build system via its winbuild scripts, which is far more reliable than manually tweaking Visual Studio project settings. Here's how to use it:

  1. Open a Visual Studio Command Prompt matching your target architecture (x86, x64, etc.—you'll find this in the Visual Studio "Tools" folder in the Start Menu).
  2. Navigate to the winbuild directory in your source folder:
    cd C:\curl-source\winbuild
    
  3. Run this nmake command to enable only the features you need:
    nmake /f Makefile.vc mode=static WITH_SMTP=yes WITHOUT_SSL=yes WITHOUT_SSH=yes PROTOCOLS="http smtp"
    
    Let's unpack the flags:
    • mode=static: Builds a static library (swap to mode=dll if you prefer a dynamic link library)
    • WITH_SMTP=yes: Enables SMTP protocol support explicitly
    • WITHOUT_SSL=yes: Disables all SSL-related dependencies (since you don't need them)
    • WITHOUT_SSH=yes: Turns off SSH/SCP/SFTP support
    • PROTOCOLS="http smtp": Restricts the build to only HTTP (for file downloads) and SMTP (for email sending) to keep it lightweight.

Step 3: Locate the Compiled Binary

Once the build finishes successfully, your custom curl.exe will be in the builds subfolder of your source directory. For example, a 64-bit static release build would live at:

C:\curl-source\builds\libcurl-vc-x64-static-release\bin\curl.exe

Step 4: Verify the Build

Test your new binary to confirm SMTP is enabled:

  1. Open a regular command prompt, navigate to the folder containing your new curl.exe
  2. Run:
    curl --version
    
    Look for the "Protocols" line—it should explicitly list http and smtp. If it does, you're ready to send emails and download files without that error.

Troubleshooting Quick Fixes

  • Missing build tools? Ensure you're using the Visual Studio Command Prompt (not a regular cmd window)—it sets up all necessary environment variables for compiling.
  • SMTP still not listed? Double-check your nmake command for typos—did you include WITH_SMTP=yes and add smtp to the PROTOCOLS flag?
  • Need a DLL instead? Swap mode=static to mode=dll in the nmake command.

内容的提问来源于stack exchange,提问作者J. Doe Junior

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:27:10