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

PHP对接DocuSign:如何格式化签署人自定义邮件正文?

Fixing Unwanted Auto-Indentation in DocuSign Plain-Text Email Body

Hey there! Let's sort out that auto-indent issue you're facing with your DocuSign recipient emails. Since you're restricted to plain-text content (your $pdEmailBody doesn't support HTML), here are a few practical fixes to get all your text left-aligned with zero indentation:

1. Strip Leading Whitespace From Every Line

DocuSign's plain-text renderer often picks up accidental leading spaces or tabs in your content. You can clean this up easily using PHP's array functions to trim each line individually:

// Split the body into lines, trim whitespace from each line, then rejoin
$cleanedEmailBody = implode("\n", array_map('trim', explode("\n", $pdEmailBody)));

Use this cleaned $cleanedEmailBody value instead of the original $pdEmailBody when configuring your RecipientEmailNotification.

2. Standardize Line Endings

Inconsistent line breaks (like mixing \n and \r\n) can sometimes trigger unexpected rendering behavior. Stick to a single line ending format—either \n (Unix/Linux) or \r\n (Windows) depending on your environment—and remove any unnecessary empty lines between paragraphs.

3. Audit Your Source Content

Double-check where $pdEmailBody originates. If it's pulled from a database, text file, or user input, there might be hidden leading whitespace that's sneaking into your emails. Manually inspect the raw content to confirm no unintended spaces are at the start of each paragraph.

Updated Code Snippet

Here's how to integrate the cleaned body into your existing code:

// First clean up the email body
$cleanedEmailBody = implode("\n", array_map('trim', explode("\n", $pdEmailBody)));

$signer1 = new \DocuSign\eSign\Model\Signer([ 
    'email' => $pdEmail, 
    'name' => $pdName, 
    "recepient_id" => "1", 
    'routing_order' => "1", 
    'email_notification' => new \DocuSign\eSign\Model\RecipientEmailNotification([ 
        'email_subject' => $pdEmailSub, 
        'email_body' => $cleanedEmailBody 
    ]) 
]);

This should eliminate those annoying auto-indents and keep your email content neatly left-aligned for all recipients.

内容的提问来源于stack exchange,提问作者shah

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.28 18:57:34