app广网 Unimarketing 邮件营销 EDM

SMTP API文档

1. 入口

  • 地址:smtp.unimarketing.org
  • 端口:25和2525

2. SMTP帐户密码

  • 从“系统设置”->“API Key 管理”获取SMTP帐户密码:
    • SMTP 帐户:{Consumer Key}
    • SMTP 密码:{Consumer Secret}

3. SMTP信头参数

  • 信头参数体育:
  • 信头 说明 备注
    X-Qos 邮件类型
    transactional缺省为网站邮件不用设置此参数
    bulk非网站交易邮件
    X-Campaign 邮件名称 指定本次体育所采用的邮件名称,如果邮件名称不存在,则会自动创建。
    X-List lol体育 指定将邮件体育者添加到的lol体育。如果lol体育不存在,则会创建。
    X-Tracking-Id 自定义标识 非必填,会在Webhook回调接口数据中回传,见:Webhook的trackingId字段 如果一次体育多封邮件,可以定义多个标识并使用逗号分隔,每个标识长度不能大于60个字符,超出部分会被忽略。
    X-Tracking-Data 自定义数据 非必填,会在Webhook回调接口数据中回传,见:Webhook的trackingData字段 如果一次体育多封邮件,在每一封邮件的回调中都会带上该数据,长度不能大于1000个字符,超出部分会被忽略。

4. 要求和限制

  • 1. X-List和X-Campaign,如果包含中文,需要使用BASE64编码。(B编码);
  • 2. 每次调用只能填写五个邮件接收人地址,多于五个时,则不会处理这次调用,会关注如下响应:
    452 Too many recipients to the message, Please reduce the number of recipients less than or equal to 5 recipients and retry
  • 3. 确保lol体育和体育计划不能大于250个字符;
  • 4. 附件限制64KB。
  • 5. 网站邮件(如密码找回)和营销邮件(如情人节促销通知)将使用不同的处理流程和优先级,为了避免网站邮件与营销邮件相互干扰,请一定要为营销邮件添加X-Qos值为“bulk”的信头
  • 6. 如果您想对API邮件中的链接点击数据进行追踪,请在邮件a标签中添加非完全数字类型的link属性,例如:
    <a href="//techsdiary.com/imagespage/http://www.website.com" link="site_1" ...
    注:不同链接的link属性值不能重复,如果重复则视为同一个链接,这些链接的点击数据会合并在一起统计
  • 7. 为了优化lol体验,您需要在邮件中添加退订系统链接,以方便lol进行退订,降低lol直接向ISP投诉导致体育信誉度降低的风险。

5. 调用响应示例

  • 1. 响应正文示例(单封邮件):正常调用
    250 ok: Message 22201212005849505.27832346.23084.18674 accepted
    
  • 2. 响应正文示例(单封邮件):含有警告信息
    250 ok: Message 22201212005849505.27832346.23084.18674 accepted, Warnning : recipients quota reached
    
  • 3. 响应正文示例(多封邮件):
    250 ok: Message 22201212005849505.27832346.23084.18674 and left 18 messages accepted
    
  • 4. 响应正文示例(多封邮件):含有警告信息
    250 ok: Message 22201212005849505.27832346.23084.18674 and left 25 messages accepted, Warnning : recipients quota reached
    
  • 5. 响应正文示例(多封邮件):含有警告信息和无效地址提示
    250 ok: Message 22201212005849505.27832346.23084.18674 and left 25 messages accepted, Warnning : recipients quota reached; invalid mailbox ignowntipt@mail.ru is unavailable. http://www.techsdiary.com/help/about_delivery.html#bad-mailbox
    
  • 6. 响应正文示例(多封邮件):含有警告信息和退订地址提示(退订只针对营销邮件)
    250 ok: Message 22201606019253710.47039368.95477.66283 and left 2 messages accepted, Warnning : messages quota reached, unsubscribed mailbox 370049196@qq.com is unavailable
    
  • 备注:
    上面正文中"22201606019253710"是这次调用唯一标识,结合Webhook可以追踪这封邮件的投递送达状态,邮件的打开点击等用户行为
    

6. 调用示例

  • 1. Java调用示例:
    import java.util.Properties;
    import javax.activation.DataHandler;
    import javax.activation.DataSource;
    import javax.activation.FileDataSource;
    import javax.mail.Authenticator;
    import javax.mail.Message;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeMultipart;
    import javax.mail.internet.MimeUtility;
    import org.apache.commons.lang3.StringUtils;
    public class MySMTP {
    private static final String SMTP_SERVER = "smtp.unimarketing.org";
    private static final String APIKey = "您的API Key";
    private static final String APISecret = "您的API Secret";
    public static void main(String[] args) throws Exception {
    Properties properties = new Properties();
    properties.put("mail.smtp.host", SMTP_SERVER);
    properties.put("mail.smtp.auth", "true");
    properties.put("mail.smtp.port", "25");
    properties.put("mail.transport.protocol", "smtp");
    String fromAddress = "no-reply@example.com";
    String recipient = "someone@customer.com";
    String subject = "邮件主题";
    String fileAttachment = "附件路径";
    String content = "邮件正文内容";
    InternetAddress[] receiveAddresses = new InternetAddress[] { new InternetAddress(recipient) };
    Session session = Session.getInstance(properties, new SmtpAuth());
    session.setDebug(true);
    session.setDebugOut(new PrintStream("smtp.log"));
    MimeMessage message = new MimeMessage(session);
    MimeMultipart multipart = new MimeMultipart();
    multipart.setSubType(ContentTypeEnum.ALTERNATIVE.getLabel());
    MimeBodyPart bodyPart = new MimeBodyPart();
    bodyPart.setContent(content, "text/html; charset=utf-8");
    multipart.addBodyPart(bodyPart);
    if (StringUtils.isNotBlank(fileAttachment)) {
    DataSource dataSource = new FileDataSource(fileAttachment);
    String name = dataSource.getName();
    bodyPart = new MimeBodyPart();
    bodyPart.setDataHandler(new DataHandler(dataSource));
    bodyPart.setFileName(MimeUtility.encodeText(name));
    multipart.addBodyPart(bodyPart);
    }
    message.setSubject(subject);
    message.setContent(multipart);
    message.setFrom(new InternetAddress(fromAddress));
    message.setRecipients(Message.RecipientType.TO, receiveAddresses);
    InternetAddress[] addresses = new InternetAddress[1];
    addresses[0] = new InternetAddress("someone@somewhere.com");
    message.setReplyTo(addresses);
    message.addHeader("X-List", MimeUtility.encodeText("lol体育名称"));
    message.addHeader("X-Campaign", MimeUtility.encodeText("邮件名称"));
    Transport.send(message);
    /**
    * 获取关注信息
    */
    File file = new File("smtp.log");
    BufferedReader reader = null;
    try {
    reader = new BufferedReader(new FileReader(file));
    String tempString = null;
    while ((tempString = reader.readLine()) != null) {
    if (tempString.lastIndexOf("250 ok:") != -1) {
    System.out.println("关注数据为:" + tempString);
    }
    }
    reader.close();
    } catch (IOException e) {
    e.printStackTrace();
    } finally {
    if (reader != null) {
    reader.close();
    }
    }
    System.out.println("体育成功");
    }
    static class SmtpAuth extends Authenticator {
    public PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication(USER_NAME, PASSWORD);
    }
    }
    }
    
  • 2. 邮件客户端调用示例:
平台介绍
关于我们 | 联系我们 | 行业应用 | 专业术语 | 资源中心 | 隐私声明
版权所有 Copyright 2005-2019 app广网(北京)科技有限公司 - 京ICP备1608763号