Ich habe also einen HTTP-Endpunkt für den Empfang verschiedener Arten von Ereignissen von SparkPost (wie Delivery, Bounce, Complaint, Open Track, ...). Alles funktioniert gut, aber ich bekomme keine Posts über Click-Ereignisse. Hier ist, was ich bisher versucht:SparkPost - keine Click-Ereignisse erhalten
private void sendEmail(String from, String[] recipients) throws SparkPostException {
TransmissionWithRecipientArray transmission = new TransmissionWithRecipientArray();
ArrayList<String> tags = new ArrayList<String>();
tags.add("tag #1");
tags.add("tag #2");
// Populate Recipients
List<RecipientAttributes> recipientArray = new ArrayList<RecipientAttributes>();
for (String recipient : recipients) {
RecipientAttributes recipientAttribs = new RecipientAttributes();
recipientAttribs.setAddress(new AddressAttributes(recipient));
recipientAttribs.setTags(tags);
recipientArray.add(recipientAttribs);
}
transmission.setRecipientArray(recipientArray);
// Populate Substitution Data
Map<String, Object> substitutionData = new HashMap<String, Object>();
substitutionData.put("link", "http://www.google.com?utm_campaign=test_campaign");
OptionsAttributes optionsAttributes = new OptionsAttributes();
optionsAttributes.setClickTracking(true); // THIS DOESN'T SEEM TO MAKE A DIFFERENCE
optionsAttributes.setOpenTracking(true);
transmission.setSubstitutionData(substitutionData);
transmission.setOptions(optionsAttributes);
transmission.setCampaignId("test_campaign");
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("user_type", "test");
transmission.setMetadata(metadata);
transmission.setReturnPath("[email protected]");
// Populate Email Body
TemplateContentAttributes contentAttributes = new TemplateContentAttributes();
contentAttributes.setFrom(new AddressAttributes(from));
contentAttributes.setSubject("Your subject content here.");
contentAttributes.setText("Your Text content here.");
contentAttributes.setHtml("<p>Your <b>HTML</b> content here. {{ link }}</p>");
transmission.setContentAttributes(contentAttributes);
transmission.setContentAttributes(contentAttributes);
// Send the Email
RestConnection connection = new RestConnection(this.client, getEndPoint());
Response response = ResourceTransmissions.create(connection, 0, transmission);
System.out.println("Transmission Response: " + response);
}
Hey @peech :) Hast du eine dieser E-Mails an dich selbst gesendet? Ich bin der Meinung, dass Ihre Verknüpfung nicht mehr verfügbar ist, da Sie doppelte geschweifte Klammern verwenden. Probieren Sie Triple-Curlies {{{link}}} aus, um das Entweichen von HTML zu verhindern. – cfs
Das funktioniert auch nicht:/Wenn ich 'Google' direkt in 'contentAttributes.setHtml()' setze, erhalte ich ein Click Event. Wenn Sie es aus 'substitutionData' einfügen, kommt Click Event nicht an. – peech
Zeigt die Domain in der E-Mail, die Sie erhalten, auf den SparkPost-Klickserver, d. H. Spgo.io, oder ist es google.com? –