SendMail.Sign
-------------

Signs the email.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SendMail](component_SendMail.md) | [11.4](newinversion114.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SendMail.Sign"; EmailID; X509Ref; PKeyRef ) 

**MBS**( **"SendMail.Sign";** /\* Signs the email. \*/  
**$EmailID**; /\* The email reference number obtained using [SendMail.CreateEmail](SendMailCreateEmail.md) function. \*/   
**$X509Ref**; /\* The reference to the X509 certificate.e.g. $cert \*/   
**$PKeyRef**) /\* The reference to the private key.e.g. $pkey \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| EmailID | The email reference number obtained using [SendMail.CreateEmail](SendMailCreateEmail.md) function. | $EmailID |
| X509Ref | The reference to the X509 certificate. | $cert |
| PKeyRef | The reference to the private key. | $pkey |

### Result

Returns OK or error.

### Description

Signs the email.  
Wraps email source with S/Mime signature.  
Please make sure you assemble the email before as doing changes later will remove the signature.  
  
After signing, you can use [SendMail.PrepareCURL](SendMailPrepareCURL.md) or [SendMail.GetSource](SendMailGetSource.md).  
### Examples

Sign an email:

 Set Variable \[ $cert ; Value: MBS ( "X509.ReadFromContainer"; EMail::Certificate ) \]   
Set Variable \[ $key ; Value: MBS ( "[PKey.Read](PKeyRead.md)"; EMail::PrivateKey ) \]   
  
Set Variable \[ $r ; Value: MBS ("SendMail.Sign"; $EmailID ; $cert ; $key ) \]   
If \[ MBS ("IsError") \]   
 Show Custom Dialog \[ "Failed to sign email" ; $r \]   
End If  
  
Set Variable \[ $r ; Value: MBS ( "[PKey.Release](PKeyRelease.md)"; $key ) \]   
Set Variable \[ $r ; Value: MBS ( "X509.Release"; $cert ) \]  
### See also

- [IsError](IsError.md)
- [PKey.Read](PKeyRead.md)
- [PKey.Release](PKeyRelease.md)
- [SendMail.CreateEmail](SendMailCreateEmail.md)
- [SendMail.GetSource](SendMailGetSource.md)
- [SendMail.PrepareCURL](SendMailPrepareCURL.md)
- [X509.Read](X509Read.md)
- [X509.ReadFromContainer](X509ReadFromContainer.md)
- [X509.Release](X509Release.md)

### Release notes

- **Version 11.4**
    - Added [SendMail.Sign](https://www.mbsplugins.eu/SendMailSign.shtml) function to send S/MIME signed emails.

### Blog Entries

- [New in MBS FileMaker Plugin 11.4](https://www.mbsplugins.de/archive/2021-09-15/New_in_MBS_FileMaker_Plugin_11/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 11.4](https://www.mbsplugins.de/archive/2021-09-07/Neues_MBS_FileMaker_Plugin_114/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.4 - More than 6500 Functions In One Plugin](https://www.mbsplugins.de/archive/2021-09-07/MBS_FileMaker_Plugin_114_-_Mor/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.4pr4](https://www.mbsplugins.de/archive/2021-08-30/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.4pr3](https://www.mbsplugins.de/archive/2021-08-25/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 22nd August 2021 , last changed 1st August 2025

  
[SendMail.SetUseSSL](SendMailSetUseSSL.md) - [SerialPort.AvailableBytes](SerialPortAvailableBytes.md)

[HTML Version](SendMailSign.shtml)