SendMail.PrepareCURL
--------------------

Setups existing CURL session for an email transfer.

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

MBS( "SendMail.PrepareCURL"; EmailID; CURLID ) 

**MBS**( **"SendMail.PrepareCURL";** /\* Setups existing CURL session for an email transfer. \*/  
**$EmailID**; /\* The email reference number obtained using [SendMail.CreateEmail](SendMailCreateEmail.md) function. \*/   
**$CURLID**) /\* The CURL session handle.e.g. $curl \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| EmailID | The email reference number obtained using [SendMail.CreateEmail](SendMailCreateEmail.md) function. | $EmailID |
| CURLID | The CURL session handle. | $curl |

### Result

Returns OK or error.

### Description

Setups existing CURL session for an email transfer.  
You can set your own settings like proxy after this function call.  
If you like you can reuse the email and curl objects after you sent an email, change values and send another email.  
  
Once you passed email content to CURL, you can configure more CURL options, e.g. use [CURL.SetOptionPort](CURLSetOptionPort.md). When you call [CURL.Perform](CURLPerform.md) and you get back an "OK", the email was sent to the mail server. You may see in the CURL log a message like "250 2.0.0 Ok: queued" to tell you that the email was received and stored. The email server will later decide whether your email is spam and then discarded or valid and delivered.  
  
### Examples

Setup and send email with all options:

 Set Variable \[$EmailID ; Value:MBS ("[SendMail.CreateEmail](SendMailCreateEmail.md)")\]  
Set Variable \[$r ; Value:MBS ("[SendMail.SetFrom](SendMailSetFrom.md)"; $EmailID ; EMail::FromEmail ; EMail::FromName )\]  
Set Variable \[$r ; Value:MBS ("[SendMail.SetHTMLText](SendMailSetHTMLText.md)"; $EmailID ; EMail::HTMLText )\]  
Set Variable \[$r ; Value:MBS ("[SendMail.SetPlainText](SendMailSetPlainText.md)"; $EmailID ; EMail::PlainText )\]  
Set Variable \[$r ; Value:MBS ("[SendMail.SetSubject](SendMailSetSubject.md)"; $EmailID ; EMail::Subject )\]  
Set Variable \[$r ; Value:MBS ("[SendMail.SetSMTPServer](SendMailSetSMTPServer.md)"; $EmailID ; EMail::SMTP Server; EMail::SMTP SSL)\]  
Set Variable \[$r ; Value:MBS ("[SendMail.SetSMTPUserName](SendMailSetSMTPUserName.md)"; $EmailID ; EMail::SMTP Username)\]  
Set Variable \[$r ; Value:MBS ("[SendMail.SetSMTPPassword](SendMailSetSMTPPassword.md)"; $EmailID ; EMail::SMTP Password)\]  
Set Variable \[$r ; Value:MBS ("[SendMail.AddTo](SendMailAddTo.md)"; $EmailID ; Recipient::Email ; Recipient::Name )\]  
Set Variable \[$r ; Value:MBS ("[SendMail.AddCC](SendMailAddCC.md)"; $EmailID ; Recipient::Email ; Recipient::Name )\]  
Set Variable \[$r ; Value:MBS ("[SendMail.AddBCC](SendMailAddBCC.md)"; $EmailID ; Recipient::Email ; Recipient::Name )\]  
Set Variable \[$r ; Value:MBS ("[SendMail.AddAttachmentContainer](SendMailAddAttachmentContainer.md)"; $EmailID ; Attachment::Container ; Attachment::Name ; Attachment::Type )\]  
Set Variable \[$r ; Value:MBS ("[SendMail.AddAttachmentFile](SendMailAddAttachmentFile.md)"; $EmailID ; Attachment::Path ; Attachment::Name ; Attachment::Type )\]  
Set Field \[EMail::EmailSource ; MBS ( "[Text.ReplaceNewLine](TextReplaceNewLine.md)"; MBS ("[SendMail.GetSource](SendMailGetSource.md)"; $EmailID ); 1)\]  
Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
Set Variable \[$r ; Value:MBS ("SendMail.PrepareCURL"; $EmailID ; $curl )\]  
Set Variable \[$r ; Value:MBS ("[CURL.Perform](CURLPerform.md)"; $curl )\]  
Set Field \[EMail::DebugInput ; MBS ("[CURL.GetHeaders](CURLGetHeaders.md)”; $curl ) \]  
Set Field \[EMail::DebugMessages ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl ) \]  
Set Variable \[$r ; Value:MBS ("[CURL.Release](CURLRelease.md)"; $curl )\]  
Set Variable \[$r ; Value:MBS ("[SendMail.Release](SendMailRelease.md)"; $EmailID )\]  
Setup to use MobileMe server for sending:

 Set Variable \[ $EmailID ; Value: MBS ("[SendMail.CreateEmail](SendMailCreateEmail.md)") \]   
\# ... later ...   
Set Variable \[ $r ; Value: MBS ("[SendMail.SetSMTPServer](SendMailSetSMTPServer.md)"; $EmailID ; "smtp.mail.me.com") \]   
Set Variable \[ $r ; Value: MBS ("[SendMail.SetSMTPUserName](SendMailSetSMTPUserName.md)"; $EmailID ; "someone@me.com") \]   
Set Variable \[ $r ; Value: MBS ("[SendMail.SetSMTPPassword](SendMailSetSMTPPassword.md)"; $EmailID ; "xxxxxx") \]   
\# ... later ...   
Set Variable \[ $r ; Value: MBS ("SendMail.PrepareCURL"; $EmailID ; $curl ) \]   
\# ... later ...   
Set Variable \[ $r ; Value: MBS ("[CURL.SetOptionPort](CURLSetOptionPort.md)"; $curl ; 587) // custom port \]   
Set Variable \[ $r ; Value: MBS ("[CURL.SetOptionUseSSL](CURLSetOptionUseSSL.md)"; $curl ; 3) // full SSL \]   
Set Variable \[ $r ; Value: MBS ("[CURL.SetOptionSSLVersion](CURLSetOptionSSLVersion.md)"; $curl ; 6) // TLS v1.2 \]  
Setup to use Office 365 server for sending:

 Set Variable \[ $EmailID ; Value: MBS ("[SendMail.CreateEmail](SendMailCreateEmail.md)") \]   
\# ... later ...   
Set Variable \[ $r ; Value: MBS ("[SendMail.SetSMTPServer](SendMailSetSMTPServer.md)"; $EmailID ; "smtp.office365") \]   
Set Variable \[ $r ; Value: MBS ("[SendMail.SetSMTPUserName](SendMailSetSMTPUserName.md)"; $EmailID ; "someone@me.com") \]   
Set Variable \[ $r ; Value: MBS ("[SendMail.SetSMTPPassword](SendMailSetSMTPPassword.md)"; $EmailID ; "xxxxxx") \]   
\# ... later ...   
Set Variable \[ $r ; Value: MBS ("SendMail.PrepareCURL"; $EmailID ; $curl ) \]   
\# ... later ...   
Set Variable \[ $r ; Value: MBS ("[CURL.SetOptionPort](CURLSetOptionPort.md)"; $curl ; 587) // custom port \]   
Set Variable \[ $r ; Value: MBS ("[CURL.SetOptionUseSSL](CURLSetOptionUseSSL.md)"; $curl ; 3) // require encryption \]   
Set Variable \[ $r ; Value: MBS ("[CURL.SetOptionSSLVersion](CURLSetOptionSSLVersion.md)"; $curl ; 6) // TLS v1.2 \]  
Set Variable \[ $r ; Value: MBS ("[CURL.SetOptionLoginOptions](CURLSetOptionLoginOptions.md)"; $curl ; "AUTH=LOGIN") \]  
### See also

- [SendMail.AddBCC](SendMailAddBCC.md)
- [SendMail.AddCC](SendMailAddCC.md)
- [SendMail.CreateEmail](SendMailCreateEmail.md)
- [SendMail.Release](SendMailRelease.md)
- [SendMail.SetFrom](SendMailSetFrom.md)
- [SendMail.SetHTMLText](SendMailSetHTMLText.md)
- [SendMail.SetPlainText](SendMailSetPlainText.md)
- [SendMail.SetSMTPServer](SendMailSetSMTPServer.md)
- [SendMail.SetSubject](SendMailSetSubject.md)
- [SendMail.Sign](SendMailSign.md)

### Release notes

- **Version 15.0**
    - Changed functions returning CURL errors to mark this as error, so [IsError](https://www.mbsplugins.eu/IsError.shtml) function returns true. This affects [CURL.Perform](https://www.mbsplugins.eu/CURLPerform.shtml), [CURL.FormClear](https://www.mbsplugins.eu/CURLFormClear.shtml), [CURL.FormFinish](https://www.mbsplugins.eu/CURLFormFinish.shtml), [CURL.Upkeep](https://www.mbsplugins.eu/CURLUpkeep.shtml), [CURL.SendText](https://www.mbsplugins.eu/CURLSendText.shtml), [CURL.SendData](https://www.mbsplugins.eu/CURLSendData.shtml), [CURL.PerformAsync](https://www.mbsplugins.eu/CURLPerformAsync.shtml), [CURL.WebSocketSend](https://www.mbsplugins.eu/CURLWebSocketSend.shtml), [CURL.WebSocketReceive](https://www.mbsplugins.eu/CURLWebSocketReceive.shtml), CURL.SetSocketNonBlocking, CURL.SetSocketNonBlocking, [SendMail.PrepareCURL](https://www.mbsplugins.eu/SendMailPrepareCURL.shtml) and various CURL.SetOption functions.

### Example Databases

- [CURL/Email/Batch Emailer](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Batch%20Emailer.shtml#1ScriptAnchor_)
- [CURL/Email/Build and send Email](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Build%20and%20send%20Email.shtml#1ScriptAnchor_)
- [CURL/Email/Build and send HTML Email with inline graphics](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Build%20and%20send%20HTML%20Email%20with%20inline%20graphics.shtml#1ScriptAnchor_)
- [CURL/Email/GMail oAuth SMTP](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/GMail%20oAuth%20SMTP.shtml#5ScriptAnchor_)
- [CURL/Email/Office 365 oAuth SMTP](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Office%20365%20oAuth%20SMTP.shtml#5ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 15.0pr9](https://www.mbsplugins.de/archive/2025-01-10/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Advent calendar - Door 12 - Sending Mails](https://www.mbsplugins.de/archive/2024-12-12/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin Advent calendar: 21 - SendMail](https://www.mbsplugins.de/archive/2023-12-21/MBS_Plugin_Advent_calendar_21_/monkeybreadsoftware_blog_filemaker)
- [SMTP with OAuth for Office 365 in FileMaker](https://www.mbsplugins.de/archive/2022-11-22/SMTP_with_OAuth_for_Office_365/monkeybreadsoftware_blog_filemaker)
- [Sending email with a huge custom function](https://www.mbsplugins.de/archive/2021-06-26/Sending_email_with_a_huge_cust/monkeybreadsoftware_blog_filemaker)
- [Use Inline Graphics in Emails](https://www.mbsplugins.de/archive/2021-02-11/Use_Inline_Graphics_in_Emails/monkeybreadsoftware_blog_filemaker)
- [Translating Insert from URL options for CURL to MBS Plugin calls](https://www.mbsplugins.de/archive/2020-12-14/Translating_Insert_from_URL_op/monkeybreadsoftware_blog_filemaker)
- [Email Script for FileMaker](https://www.mbsplugins.de/archive/2018-10-10/Email_Script_for_FileMaker/monkeybreadsoftware_blog_filemaker)
- [Sending emails in FileMaker with MBS Plugin](https://www.mbsplugins.de/archive/2016-10-03/Sending_emails_in_FileMaker_wi/monkeybreadsoftware_blog_filemaker)
- [Sending Email with FileMaker via MBS Plugin](https://www.mbsplugins.de/archive/2014-09-29/Sending_Email_with_FileMaker_v/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2024, Seite 38 bis 39](https://filemaker-magazin.de/neuigkeit/4277-Appetithappen-FMM_202406)
- [Ausgabe 5/2014, Seite 26](https://filemaker-magazin.de/neuigkeit/3759-Appetithappen-FMM_201405)

This function checks for a license.

Created 3th September 2014 , last changed 3th January 2023

  
[SendMail.GetUseSSL](SendMailGetUseSSL.md) - [SendMail.Release](SendMailRelease.md)

[HTML Version](SendMailPrepareCURL.shtml)