Email Service

APIEmailService allows you to email your contacts as well as attaching emails sent elsewhere (this lets you send email from multiple services and still see all communications inside of Infusionsoft).


EmailService.addEmailTemplate

Create a new email template that can be used for future emails

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
pieceTitle string The name of the template. This will be displayed within the Infusionsoft template library
categories string The category of templates you would like this template saved in fromAddress - The from email address this template sends as. Format: "FirstName LastName "
fromAddress string The email address this template sends from."
toAddress string The email address this template sends to. Typically this will be "~Contact.Email~"
ccAddress string Any email addresses you would like to CC when this template is sent
bccAddress string Any email address you would like to BCC when this template is sent
subject string The subject line for this email template
textBody string The content you would like sent in the body of the plain text version of this email template
htmlBody string The HTML that makes up the body of this template. If you only send plain text emails
contentType string HTML, Text, or Multipart
mergeContext string Contact, Opportunity, Invoice, or CreditCard

Returns

Return: (int) templateId of the created email template

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>APIEmailService.addEmailTemplate</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>title</string></value>
    </param>
    <param>
      <value><string>categories</string></value>
    </param>
    <param>
      <value><string>fromAddress</string></value>
    </param>
    <param>
      <value><string>toAddress~Contact.Email~</string></value>
    </param>
    <param>
      <value><string>ccAddresses</string></value>
    </param>
    <param>
      <value><string>bccAddresses</string></value>
    </param>
    <param>
      <value><string>subject</string></value>
    </param>
    <param>
      <value><string>textBody</string></value>
    </param>
    <param>
      <value><string>htmlBody</string></value>
    </param>
    <param>
      <value><string>contentType</string></value>
    </param>
    <param>
      <value><string>mergeContext</string></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value><i4>3378</i4></value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$title = "template API test";
$category = "API Category";
$fromAddress = "from@infusionsoft.com";
$toAddress = "~Contact.Email~";
$ccAddress = "";
$bccAddresses = "";
$subject = "My Fancy Subject Line";
$textBody = "This is the text email body";
$htmlBody = "HTML"
$contentType = "Contact";
$mergeContext = "";
$tmpId = $app->addEmailTemplate($title, $category, $fromAddress, $toAddress, $ccAddress, $bccAddresses, $subject, $textBody, $htmlBody, $contentType, $mergeContext);

EmailService.attachEmail

This will create an item in the email history for a contact. This does not actually send the email, it only places an item into the email history. Using the API to instruct Infusionsoft to send an email will handle this automatically.

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
contactId int The Id of the contact you would like to add this email history to
fromName string The name portion of the from address. I.E. FirstName LastName, not the email@domain.com portion
fromAddress string The email address the email was sent from
toAddress string The email address the email was sent to
ccAddresses string Any email address that was CC'd
bccAddresses string Any email address that was BCC'd
contentType string What type of email this was. Text, HTML, or Multipart (case sensitive)
subject string The subject line
htmlBody string The html from the body of the email
textBody string The plain text body of the email
header string The email header information
receivedDate string The date this email was received. This determines where this displays in comparison to other emails
sentDate string The date this email was sent
emailSentType int A boolean int, 1 is used for marking the email as sent inside the contact history and 0 is used for marking the email as received

Returns

Return: (boolean) True/False

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>APIEmailService.attachEmail</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><int>contactId</int></value>
    </param>
    <param>
      <value><string>fromName</string></value>
    </param>
    <param>
      <value><string>fromAddress</string></value>
    </param>
    <param>
      <value><string>toAddress</string></value>
    </param>
    <param>
      <value><string>ccAddress</string></value>
    </param>
    <param>
      <value><string>bccAddress</string></value>
    </param>
    <param>
      <value><string>contentType</string></value>
    </param>
    <param>
      <value><string>subject</string></value>
    </param>
    <param>
      <value><string>htmlBody</string></value>
    </param>
    <param>
      <value><string>textBody</string></value>
    </param>
    <param>
      <value><string>header</string></value>
    </param>
    <param>
      <value><string>receivedDate</string></value>
    </param>
    <param>
      <value><string>sentDate</string></value>
    </param>
    <param>
      <value><int>emailSentType(Set To 1)</int></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value><boolean>1</boolean></value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$contactId = 123;
$fromName = "John Doe";
$fromAddress = "JDoe@test.com";
$toAddress = "Tester@test.com";
$ccAddress = "cc@test.com";
$bccAddress = "bcc$test.com";
$contentType = "TEXT";
$subject = "test subject";
$htmlBody = "html here";
$textBody = "Test Body Can Be Anything";
$header = "Email header";
$receiveDate = "";
$sentDate = "";
$emailSentType = 1;
$status = $app->attachEmail($contactId, $fromName, $fromAddress, $toAddress, $ccAddress, $bccAddress, $contentType, $subject, $htmlBody, $textBody, $header, $receiveDate, $sentDate, $emailSentType);

This retrieves all possible merge fields for the context provided

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
mergeContext string Contact, Opportunity, Invoice, or CreditCard

Returns

Return: (array) the available merge fields for the given context

Sample Request


Sample Response


PHP iSDK Sample

This method is not currently built into the iSDK


EmailService.getEmailTemplate

Retrieves the details for a particular email template

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
templateId int The Id number for the template you wish to retrieve details about

Returns

Returns: (array) all data for a particular email template
Example:
Struct(
[pieceTitle] => Example
[categories] => Email
[fromAddress] => example@example.com
[toAddress] => ~Contact.Email~
[ccAddress] =>
[bccAddress] =>
[subject] => Example Subject
[textBody] => Some example body
[htmlBody] => Some HTML here
[contentType] => HTML
[mergeContext] => Contact
)

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>APIEmailService.getEmailTemplate</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><int>templateId</int></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value>
        <struct>
          <member>
            <name>pieceTitle</name>
            <value>template API Test</value>
          </member>
          <member>
            <name>categories</name>
            <value>API Category</value>
          </member>
          <member>
            <name>fromAddress</name>
            <value>from@infusionsoft.com</value>
          </member>
          <member>
            <name>toAddress</name>
            <value>~Contact.Email~</value>
          </member>
          <member>
            <name>ccAddress</name>
            <value/>
          </member>
          <member>
            <name>bccAddress</name>
            <value/>
          </member>
          <member>
            <name>subject</name>
            <value>My Fancy Subject Line</value>
          </member>
          <member>
            <name>textBody</name>
            <value>This is the text email body</value>
          </member>
          <member>
            <name>htmlBody</name>
            <value>This is html body</value>
          </member>
          <member>
            <name>contentType</name>
            <value>HTML</value>
          </member>
          <member>
            <name>mergeContext</name>
            <value>Contact</value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$tmp = $app->getEmailTemplate(42);

EmailService.getOptStatus

 

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
email string The email address you wish to retrieve the status of

Returns

Return: (int) 0 = opt out/non-marketable/soft bounce/hard bounce, 1 = single opt on, 2 = double opt in

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>APIEmailService.getOptStatus</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>email</string></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value><i4>0</i4></value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$result = $app->optStatus('test@example.com');

EmailService.optIn

This method opts-in an email address. This method only works the first time an email address opts-in

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
email string The email address to opt-in
optInReason string This is how you can note why/how this email was opted-in. *This can not be blank. You must specify a reason.

Returns

Return: (boolean) True/False

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
<methodName>APIEmailService.optIn</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>email</string></value>
    </param>
    <param>
      <value><string>reason</string></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value><boolean>0</boolean></value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$result = $app->optIn($subscriberEmail,"Home page newsletter subscriber");

EmailService.optOut

Opts-out an email address. Note that once an address is opt-out, the API cannot opt it back in

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
email string The email address to opt-out
optOutreason string Reason the address is being opt-out

Returns

Return: (boolean) True/False

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
<methodName>APIEmailService.optOut</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>email</string></value>
    </param>
    <param>
      <value><string>reason</string></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value><boolean>0</boolean></value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$result = $app->optOut($subscriberEmail,"Opted out from our website");

EmailService.sendEmail

This will send an email to a list of contacts, as well as record the email in the contacts' email history

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
contactList string An integer array of Contact Id numbers you would like to send this email to
fromAddress string The email address this template will be sent from
toAddress string The email address this template will send to. This is typically the merge field "~Contact.Email~"
ccAddresses string The email address(es) this template will carbon copy. Multiples separated by comma
bccAddresses string the email address(es) this template will blind carbon copy. Multiples separated by comma
contentType string HTML, Text, or Multipart (this is case sensitive)
subject string The subject line of this email
htmlBody string The HTML content the body of this email is comprised of
textBody string The content of the plain text body of this template
templateId (optional) string The Id number of the template you would like to send

Returns

Return: True if the email has been sent, an error will be sent back otherwise!

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
<methodName>APIEmailService.sendEmail</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><array>
        <data>
          <value><int>contactList1</int></value>
          <value><int>contactList2</int></value>
          <value><int>contactList3</int></value>
        </data>
      </array></value>
    </param>
    <param>
      <value><string>fromAddress</string></value>
    </param>
    <param>
      <value><string>toAddress</string></value>
    </param>
    <param>
      <value><string>ccAddresses</string></value>
    </param>
    <param>
      <value><string>bccAddresses</string></value>
    </param>
    <param>
      <value><string>contentType</string></value>
    </param>
    <param>
      <value><string>subject</string></value>
    </param>
    <param>
      <value><string>htmlBody</string></value>
    </param>
    <param>
      <value><string>textBody</string></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value><boolean>1</boolean></value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$clist = array(123,456,789); 
$status = $app->sendEmail($clist,"Test@test.com","~Contact.Email~", "","","Text","Test Subject","","This is the body");

EmailService.sendEmailWithStatus

This will send an email to a list of emails, as well as record the email in the contacts' email history

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
fromAddress string The email address this email will be sent from
toAddress string The email address(es) to send to. Multiples separated by comma. "test@example.com, example@example.com"
ccAddresses string The email address(es) this template will carbon copy. Multiples separated by comma
bccAddresses string the email address(es) this template will blind carbon copy. Multiples separated by comma
subject string The subject line of this email
htmlBody string The HTML content the body of this email is comprised of
textBody string The content of the plain text body of this template

Returns

The method's response will return for each recipient: 1) A boolean flag ("Successful") which indicates if the email was successfully queued. 2) The email address ("Email") of the recipient. 3) A status message ("Message"). For success - "Message queued successfully" , for failure - "Message failed: Invalid email address or contact has opted out of communications"

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
<methodName>APIEmailService.sendEmail</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>fromAddress</string></value>
    </param>
    <param>
      <value><string>toAddress</string></value>
    </param>
    <param>
      <value><string>ccAddresses</string></value>
    </param>
    <param>
      <value><string>bccAddresses</string></value>
    </param>
    <param>
      <value><string>subject</string></value>
    </param>
    <param>
      <value><string>textBody</string></value>
    </param>
    <param>
      <value><string>htmlBody</string></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
    <params>
        <param>
            <value>
                <array>
                    <data>
                        <value>
                            <struct>
                                <member>
                                    <name>Successful</name>
                                    <value>true</value>
                                </member>
                                <member>
                                    <name>Email</name>
                                    <value>text@example.com</value>
                                </member>
                                <member>
                                    <name>Message</name>
                                    <value>Message queued successfully</value>
                                </member>
                            </struct>
                        </value>
                        <value>
                            <struct>
                                <member>
                                    <name>Successful</name>
                                    <value>false</value>
                                </member>
                                <member>
                                    <name>Email</name>
                                    <value>example@test.com</value>
                                </member>
                                <member>
                                    <name>Message</name>
                                    <value>Message failed: Invalid email address or contact has opted out of
                                        communications
                                    </value>
                                </member>
                            </struct>
                        </value>
                    </data>
                </array>
            </value>
        </param>
    </params>
</methodResponse>

PHP iSDK Sample



EmailService.sendTemplate

This will send an email to a list of contacts, as well as record the email in the contacts' email history

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
contactList array An integer array of Contact Id numbers you would like to send this email to
templateId string The Id of of template to send

Returns

Return: True if the email has been sent, an error will be sent back otherwise!

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>APIEmailService.sendEmail</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><array>
      <data>
        <value><int>12</int></value>
        <value><int>16</int></value>
        <value><int>22</int></value>
      </data>
      </array></value>
    </param>
  <param>
    <value><int>3380</int></value>
  </param>
</params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value>
        <boolean>
          1
        </boolean>
      </value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$app->sendTemplate(array(12,16,22), 3380);

EmailService.updateEmailTemplate

This method is used to update an already existing email template

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
templateId string The Id number of the email template you would like to update
pieceTitle string The title/name of this template. This is the internal name, not visible to customers
category string The category you would like to save this template in
fromAddress string The email address this template will be sent from. Format: "First Last"
toAddress string The email address this template will send to. This is typically the merge field "~Contact.Email~"
ccAddress string The email address(es) this template will carbon copy. Multiples separated by comma
bccAddresses string The email address(es) this template will blind carbon copy. Multiples separated by comma
subject string The subject line of this email
textBody string The content of the plain text body of this template
htmlBody string The HTML content the body of this email is comprised of
contentType string HTML, text, or multipart (this is case sensitive)
mergeContext string Contact, Opportunity, Invoice, or CreditCard (this is typically Contact)

Returns

Return: (boolean) True/False

Sample Request


Sample Response


PHP iSDK Sample

This method is not currently built into the iSDK