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

Hybris中sendEmail动作的邮件UTF-8编码设置问题

Fixing UTF-8 Encoding for sendEmail Action

Hey there! I’ve dealt with this exact UTF-8 encoding hiccup using sendEmail before—super frustrating when everything else works but your special characters (like non-English text) get garbled. Let’s walk through the fixes based on the most common sendEmail tools out there:

Command-Line sendEmail Tool

If you’re using the popular sendEmail command-line utility, you can force UTF-8 encoding with two key parameters:

  • -o message-charset=UTF-8: Sets the character set for the email body
  • -o content-type=text/html;charset=UTF-8 (or text/plain if you’re sending plain text): Tells email clients to interpret the content as UTF-8

Here’s a full example command that covers both body and subject encoding:

sendEmail \
  -f sender@yourdomain.com \
  -t recipient@theirdomain.com \
  -s smtp.yourdomain.com \
  -u "你的UTF-8主题" \
  -m "包含中文、特殊字符的邮件内容" \
  -o message-charset=UTF-8 \
  -o subject-charset=UTF-8 \
  -o content-type=text/plain;charset=UTF-8

The subject-charset flag ensures your email subject also uses UTF-8—critical if your subject has non-ASCII characters.

Jenkins sendEmail Plugin

If you’re using Jenkins’ sendEmail plugin, the fix is straightforward in the system config or your pipeline:

  1. System-Wide Configuration:
    • Go to Manage Jenkins > Configure System
    • Scroll down to the Extended E-mail Notification section (or the core Email Notification area, depending on your plugin version)
    • Find the Default Content Type dropdown—select either Plain Text (text/plain) or HTML (text/html)
    • In the adjacent Character Set field, enter UTF-8
  2. Pipeline Step:
    If you’re defining the sendEmail action directly in a Jenkinsfile, specify the charset explicitly:
    sendEmail(
        to: 'recipient@theirdomain.com',
        subject: 'UTF-8 主题',
        body: '带有特殊字符的邮件正文',
        mimeType: 'text/plain',
        charset: 'UTF-8'
    )
    

General Tip for Other Platforms

If you’re using sendEmail in a different tool (like a custom script or low-code platform), look for options to add custom email headers. Manually include this header to enforce UTF-8:

Content-Type: text/plain; charset=UTF-8

Or for HTML emails:

Content-Type: text/html; charset=UTF-8

This tells mail clients exactly how to decode your content, so special characters display correctly.

内容的提问来源于stack exchange,提问作者Hector Gonzalez Santiago

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 06:37:50