3

I want to setup a similar message structure as in github, where a user can either respond by email or logging into his account.

Github appears to have a unique-id in the reply-to field:

reply+i-39945717-887b26ec5b3de79d00dec7ef29ad308795b85685-6876349@reply.github.com 

Is it possible to add a unique ID to the "Reply-to"-header with swift-mailer?

How would the mail server be able to work with this?

2 Answers 2

4

For responding to using email, you can use In-Reply-To alongside Reply-To.

For this purpose you can use this StackOverFlow answer: Correct headers for replying and forwarding emails
In summary you need to track your message using its ID and its id is stored in In-Reply-To and this is the way you can set it:

$headers = $message->getHeaders(); $headers->addTextHeader('In-Reply-To', $previousEmail->getHeaders()->getMessageId()); 
Sign up to request clarification or add additional context in comments.

Comments

2

Well, why not? Setting Reply-to with SwiftMailer is quite easy:

<?php $message = new \Swift_Message(); $message->setReplyTo(sprintf( 'reply+%[email protected]', uniqid() )); 

The uniquid() call is just for example. In real-life code you'd persist the entity ID beforehand (e.g. when you save it), and retrieve it from your model object later.

However, you'll need to set up a mail checker that would receive your incoming mail, parse it and transform into CRUD operations on your database.

3 Comments

the last part is actually the thing I am stuck with. Isn't The reply-to field expecting an email address?
@apfz, well, isn't it a valid email address? The + sign is allowed there, and the mail should be received by the alias without the + sign and the suffix.
did not know it was allowed. thanks for this. However PHP is not fetching the value after (and including) the plus sign (it just trims it), but for that I will post another question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.