Hi community!
I am attempting to implement list-unsubscribe and list-unsubscribe POST in all our email smtp headers.
The approach is that I have a webApp that accepts a POST call with an encrypted userId that I then decrypt in order to decline permission in our backend system.
This all works when I manually add the smtp headers in an email like so:
List-Unsubscribe-Post: List-Unsubscribe=One-Click
List-Unsubscribe: <https://tv2-mkt-prod1.campaign.adobe.com/tv2/oneClickOptOut.jssp?id=<%=cryptString(recipient.auth0)%>>
However when I implement a typology to do the same on all deliveries, the encrypted string is different, and I am no longer able to decrypt it in the webApp.
Any pointers to why this might happen and possibly how I can solve it?
I am using decryptString(encryptedString) to solve the task in the webApp.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Thank you very much for the reply!
The rule is applied at personalization phase.
For reference, this is the code that is implemented for the rule:
// Define the unsubscribe URL
var headerUnsubUrl ="https://tv2-mkt-prod1.campaign.adobe.com/tv2/oneClickOptOut.jssp?id=<%= cryptString(recipient.auth0)%>"
// Get the value of the List-Unsubscribe header
var headerUnsub = getHeader(delivery.mailParameters.headers, 'List-Unsubscribe')
// If the List-Unsubscribe header does not exist
if (headerUnsub === '') {
// Add the List-Unsubscribe header
delivery.mailParameters.headers = addHeader(delivery.mailParameters.headers,'List-Unsubscribe','<' + headerUnsubUrl + '>')
}
// If the List-Unsubscribe header exists and contains 'mailto'
else if (headerUnsub.search('mailto')) {
// Replace the existing List-Unsubscribe header
delivery.mailParameters.headers = addHeader(delivery.mailParameters.headers,'List-Unsubscribe','<' + headerUnsubUrl + '>')
}
// Get the value of the List-Unsubscribe-Post header
var headerUnsubPost = getHeader(delivery.mailParameters.headers,'List-Unsubscribe-Post')
// If the List-Unsubscribe-Post header does not exist
if (headerUnsubPost === '') {
// Add the List-Unsubscribe-Post header
delivery.mailParameters.headers = addHeader(delivery.mailParameters.headers,'List-Unsubscribe-Post','List-Unsubscribe=One-Click')
}
// Return true to indicate success
return true
// Function to add or replace a header in the provided headers
function addHeader (headers, header, value) {
// Create the new header line
var headerLine = header + ': ' + value
// Create a regular expression to find the specified header
var regExp = new RegExp(header + ':(.*)$', 'i')
// Split the headers into individual lines
var headerLines = headers.split('\n')
// Loop through each line
for (var i = 0; i < headerLines.length; i++) {
// Check if the specified header exists
var match = headerLines[i].match(regExp)
// If it exists
if (match != null) {
// Replace the existing header line
headerLines[i] = headerLine
// Return the modified headers
return headerLines.join('\n')
}
}
// If the header does not exist, add the new header line
headerLines.push(headerLine)
// Return the modified headers
return headerLines.join('\n')
}
// Function to get the value of a specified header from the provided headers
function getHeader(headers, header)
{
// Create a regular expression to find the specified header
var regExp = new RegExp(header + ':(.*)$', 'i')
// Split the headers into individual lines
var headerLines = headers.split('\n')
// Loop each line
for each(line in headerLines)
{
// Check if the specified header exists
var match = line.match(regExp)
// If it exists
if (match != null) {
// Return the header value, removing leading whitespace
return match[1].replace(/^\s*/, '')
}
}
// If the header does not exist, return an empty string
return ''
}
Views
Replies
Total Likes
It seems that it was in the end a simple mistake. The rule has to be applied in the phase: "At the start of targeting" which solved the issue. So the phase perspective was correct!
Thanks
Views
Replies
Total Likes
The cryptString() function is salted with the time, so will never produce the specific value you've been asked to get.
If you encrypt same string with same password and without salt, you will get same result
Thanks,
David
Views
Replies
Total Likes
Hi @DavidKangni
Thanks for the response! That makes total sense! Right now I am struggling to disable the use of salt. I am currently doing this in the typology rule, but it keeps giving different results each time it is run for the same input:
// Define the unsubscribe URL
var headerUnsubUrl ="https://tv2-mkt-prod1.campaign.adobe.com/tv2/oneClickOptOut.jssp?id=<%= cryptString(recipient.auth0, '', false)%>"
EDIT: It seems that the typology rule simply cannot read from the recipient table... So <%=recipient.XYZ%> results in undefined. Can't figure out how I am supposed to go about that challenge.
Views
Replies
Total Likes
Hello @SorenDP
Check the value of the XtkKey Option. It should be the same for marketing and frontal servers.
Also, I wouldn't focus on this one because only Gmail supports the URL subscribe functionality.
For now, it is best to work with the List-unsubscribe email header because it is widely supported.
Views
Replies
Total Likes
Hi @SorenDP
We are in the process of implementing list-unsubscribe post in the smtp header. Similar to what you have shared in your query. I have few questions, appreciate if you can help me with it.
1. I can see that you have mentioned that you are implementing a webapp method and the url mentioned in List Unsubscribe is refereeing to a jssp script. Can you please share more details on how you implemented this.
2. The Campaign server is hosted in our own server and is not hosted on Adobe servers. Do you suggest any configuration changes to make this implementation work?
Happy to connect with you personally to learn more on how you have implemented it in your instance.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies