Template Best Practices for SMTP Imports
How do users get content into the CMS?
In cases where it is not practical to create each page individually and where existing data can be obtained in a structured XML or comma-delimited CSV format, CrownPeak WCM offers templates for importing data over FTP (File Transfer Protocol) or SMTP (Simple Mail Transfer Protocol). This Article focuses on SMTP.
SMTP Import is preferred for small jobs where the CMS might need to receive at most a few updates an hour. The process involves an email being sent to the CMS with an email import key and the data can either be in the body of the email or in an attachement. SMTP Imports are created in smtp_import.aspx Template files. SMTP Import does not currently support base64 data.
- Existing data in XML or comma-delimited CSV
- SMTP import configuration in the CMS
- CrownPeak Template definitions providing a map from existing content to the new CrownPeak data structure
Prepare Your Data
Once you have your data in, or attached to, an email, create a new SMTP import connector in System > Configure > Import > SMTP.
Create the Import Connector
Note: As of January 2014, Import Connectors can only be configured in the classic UI.
The import connector automatically picks up emails that contain the matching Email Token.
The import can also be configured to pick up a maximum number of emails per day and to allow a maximum number of files to use the smtp configuration.
You can also manually trigger an import poll by selecting Edit > Trigger Import in the CMS.
When the import connector successfully finds a datafile in the e-mail, it will begin the import process in the CMS. The e-mail needs to have the correct import TOKEN in it, generally in the subject line, in order to be recognized by the CMS.
The template referenced in the model that the import connector uses must include an smtp_import.aspx template file which will execute when the import is successful. When executed, this template file will then automatically create or update one or more assets in the CMS.
- Build an input.aspx first to structure / validate your desired CMS fieldname structure.
- Clearly map out your existing data fields to the CMS asset fieldnames.
- You can create repeating, nested structures as list panels or as individual assets. Plan how you want this to work based on your needs. e.g., creating separate assets for each item in a collection vs creating the asset itself as a collection and panels as individual items.
- SMTP Import Token does not match.
- smtp_import.aspx import code has the wrong content fields referenced.
- smtp_import.aspx has the wrong syntax.
- Incorrect template selected as model. (Make sure to select a sample asset using a template with an smtp_import.aspx)
In the attached file is an example of smtp_import.aspx code from a project that takes the data from the import attached to an e-mail and creates a number of different "CD" assets.