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).
Create a new email template that can be used for future emails
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 |
Return: (int) templateId of the created email template
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value><i4>3378</i4></value> </param> </params> </methodResponse>
$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);
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.
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 |
Return: (boolean) True/False
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value><boolean>1</boolean></value> </param> </params> </methodResponse>
$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
Parameter Name | Type | Definition |
---|---|---|
privateKey | string | Your Infusionsoft API key |
mergeContext | string | Contact, Opportunity, Invoice, or CreditCard |
Return: (array) the available merge fields for the given context
This method is not currently built into the iSDK
Retrieves the details for a particular email template
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: (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
)
<?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>
<?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>
$tmp = $app->getEmailTemplate(42);
Parameter Name | Type | Definition |
---|---|---|
privateKey | string | Your Infusionsoft API key |
string | The email address you wish to retrieve the status of |
Return: (int) 0 = opt out/non-marketable/soft bounce/hard bounce, 1 = single opt on, 2 = double opt in
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value><i4>0</i4></value> </param> </params> </methodResponse>
$result = $app->optStatus('test@example.com');
This method opts-in an email address. This method only works the first time an email address opts-in
Parameter Name | Type | Definition |
---|---|---|
privateKey | string | Your Infusionsoft API key |
string | The email address to opt-in | |
optInReason | string | This is how you can note why/how this email was opted-in. *If a blank optInReason is passed the system will default a reason of "API Opt In" |
Return: (boolean) True/False
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value><boolean>0</boolean></value> </param> </params> </methodResponse>
$result = $app->optIn($subscriberEmail,"Home page newsletter subscriber");
Opts-out an email address. Note that once an address is opt-out, the API cannot opt it back in
Parameter Name | Type | Definition |
---|---|---|
privateKey | string | Your Infusionsoft API key |
string | The email address to opt-out | |
optOutreason | string | Reason the address is being opt-out |
Return: (boolean) True/False
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value><boolean>0</boolean></value> </param> </params> </methodResponse>
$result = $app->optOut($subscriberEmail,"Opted out from our website");
This will send an email to a list of contacts, as well as record the email in the contacts' email history
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 |
Return: True if the email has been sent, an error will be sent back otherwise!
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value><boolean>1</boolean></value> </param> </params> </methodResponse>
$clist = array(123,456,789); $status = $app->sendEmail($clist,"Test@test.com","~Contact.Email~", "","","Text","Test Subject","","This is the body");
This will send an email to a list of contacts, as well as record the email in the contacts' email history
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 |
Return: True if the email has been sent, an error will be sent back otherwise!
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value> <boolean> 1 </boolean> </value> </param> </params> </methodResponse>
$app->sendTemplate(array(12,16,22), 3380);
This method is used to update an already existing email template
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) |
Return: (boolean) True/False
This method is not currently built into the iSDK