Sample code for 30+ languages & platforms
Swift Requires Chilkat v11.0.0+

Send an email with a Bcc recipient using SMTP (live send)

See more Email Object Examples

Live send. Load the previously prepared with-attachments.eml, add a Bcc recipient, and pass the Email to MailMan.SendEmail. For a real test, use a relay you control, replace the sample sender and recipients (including the Bcc address) with test mailboxes, and obtain credentials from your application’s secret store.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    //  Assumes Chilkat is unlocked. See Global Unlock Sample.

    let email = CkoEmail()!
    success = email.loadEml(mimePath: "with-attachments.eml")
    if success != true {
        print("\(email.lastErrorText!)")
        return
    }

    //  Enable this option before adding a blind recipient to the message.
    email.uncommonOptions = "NoBccHeader"
    success = email.addBcc(friendlyName: "Bcc recipient", emailAddress: "bcc@example.net")
    if success != true {
        print("\(email.lastErrorText!)")
        return
    }

    let mail = CkoMailMan()!
    mail.smtpHost = "smtp.example.com"
    mail.smtpPort = 465
    mail.smtpSsl = true
    mail.requireSslCertVerify = true
    mail.smtpUsername = "MAIL_USER"
    mail.smtpPassword = "MAIL_PASSWORD"
    success = mail.sendEmail(email: email)
    if success != true {
        print("\(mail.lastErrorText!)")
        return
    }

    print("The SMTP relay accepted the message.")
    success = mail.closeSmtpConnection()
    if success != true {
        print("\(mail.lastErrorText!)")
        return
    }


}