Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

SendMail.PrepareCURL

Setups existing CURL session for an email transfer.

Component Version macOS Windows Linux Server iOS SDK
SendMail 4.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "SendMail.PrepareCURL"; EmailID; CURLID )   More

Parameters

Parameter Description Example
EmailID The email reference number obtained using SendMail.CreateEmail 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. When you call CURL.Perform 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")]
Set Variable [$r; Value:MBS("SendMail.SetFrom"; $EmailID; EMail::FromEmail; EMail::FromName)]
Set Variable [$r; Value:MBS("SendMail.SetHTMLText"; $EmailID; EMail::HTMLText)]
Set Variable [$r; Value:MBS("SendMail.SetPlainText"; $EmailID; EMail::PlainText)]
Set Variable [$r; Value:MBS("SendMail.SetSubject"; $EmailID; EMail::Subject)]
Set Variable [$r; Value:MBS("SendMail.SetSMTPServer"; $EmailID; EMail::SMTP Server; EMail::SMTP SSL)]
Set Variable [$r; Value:MBS("SendMail.SetSMTPUserName"; $EmailID; EMail::SMTP Username)]
Set Variable [$r; Value:MBS("SendMail.SetSMTPPassword"; $EmailID; EMail::SMTP Password)]
Set Variable [$r; Value:MBS("SendMail.AddTo"; $EmailID; Recipient::Email; Recipient::Name)]
Set Variable [$r; Value:MBS("SendMail.AddCC"; $EmailID; Recipient::Email; Recipient::Name)]
Set Variable [$r; Value:MBS("SendMail.AddBCC"; $EmailID; Recipient::Email; Recipient::Name)]
Set Variable [$r; Value:MBS("SendMail.AddAttachmentContainer"; $EmailID; Attachment::Container; Attachment::Name; Attachment::Type)]
Set Variable [$r; Value:MBS("SendMail.AddAttachmentFile"; $EmailID; Attachment::Path; Attachment::Name; Attachment::Type)]
Set Field [EMail::EmailSource; MBS( "Text.ReplaceNewline"; MBS("SendMail.GetSource"; $EmailID); 1)]
Set Variable [$curl; Value:MBS("CURL.New")]
Set Variable [$r; Value:MBS("SendMail.PrepareCURL"; $EmailID; $curl)]
Set Variable [$r; Value:MBS("CURL.Perform"; $curl)]
Set Field [EMail::DebugInput; MBS("CURL.GetHeaders”; $curl) ]
Set Field [EMail::DebugMessages; MBS("CURL.GetDebugMessages"; $curl) ]
Set Variable [$r; Value:MBS("CURL.Release"; $curl)]
Set Variable [$r; Value:MBS("SendMail.Release"; $EmailID)]

Setup to use MobileMe server for sending:

Set Variable [ $EmailID ; Value: MBS("SendMail.CreateEmail") ]
# ... later ...
Set Variable [ $r ; Value: MBS("SendMail.SetSMTPServer"; $EmailID; "smtp.mail.me.com") ]
Set Variable [ $r ; Value: MBS("SendMail.SetSMTPUserName"; $EmailID; "someone@me.com") ]
Set Variable [ $r ; Value: MBS("SendMail.SetSMTPPassword"; $EmailID; "xxxxxx") ]
# ... later ...
Set Variable [ $r ; Value: MBS("SendMail.PrepareCURL"; $EmailID; $curl) ]
# ... later ...
Set Variable [ $r ; Value: MBS("CURL.SetOptionPort"; $curl; 587) // custom port ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionUseSSL"; $curl; 3) // full SSL ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionSSLVersion"; $curl; 6) // TLS v1.2 ]

Setup to use Office 365 server for sending:

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

See also

Example Databases

Blog Entries

This function checks for a license.

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


SendMail.GetSubject - SendMail.Release