如何在HelloSign(PHP)中分别设置邮件主题与邮件内文档名称
Got it, let's break this down. That default behavior where setSubject() controls both the email subject and the document title under the DOCUMENT heading in the email body is definitely a gotcha—but there's a straightforward fix using HelloSign's PHP SDK.
Here's what you need to do:
HelloSign lets you explicitly set the document title separately from the email subject. You just need to use the right method in your signature request:
- Set the email subject as usual with
setSubject():$request->setSubject('Your Official Contract Review Request'); - Set the custom document title (the one that shows up under DOCUMENT in the email body) using
setDocumentTitle():$request->setDocumentTitle('Q3 2024 Vendor Service Agreement');
Full Example Code
Here's how this fits into a complete template-based signature request:
// Initialize the HelloSign client $client = new HelloSign\Client('YOUR_API_KEY'); // Create a template signature request $request = new HelloSign\SignatureRequestTemplate(); // Set email subject (only for the email's subject line) $request->setSubject('Action Required: Sign Your Q3 Service Contract'); // Set custom document title (shows under DOCUMENT in email body) $request->setDocumentTitle('Q3 2024 Vendor Service Agreement'); // Add your template ID and signer details $request->setTemplateId('YOUR_STORED_TEMPLATE_ID'); $request->addSigner('john.doe@example.com', 'John Doe'); // Send the request try { $response = $client->sendSignatureRequest($request); echo "Signature request sent successfully!"; } catch (HelloSign\Exception\ApiException $e) { echo "Error: " . $e->getMessage(); }
What if setDocumentTitle() isn't available?
If you're using an older version of the HelloSign PHP SDK that doesn't have the setDocumentTitle() method, you can manually add the parameter using addExtraParam():
$request->addExtraParam('document_title', 'Q3 2024 Vendor Service Agreement');
Why this works
By default, HelloSign falls back to using the email subject as the document title if no explicit document_title is provided. By setting this parameter explicitly, you override that default behavior and get separate values for the email subject and the document title in the email body.
内容的提问来源于stack exchange,提问作者Teshan N.

