zone-eu / zone-mta

📤 Modern outbound MTA cross platform and extendable server application
European Union Public License 1.2
583 stars 93 forks source link

Best way to send and use personalized headers with API #379

Closed florentjb closed 3 months ago

florentjb commented 3 months ago

Hello,

I use Zone-mta with API /send So, i need to use and get a personalized Tags like X-Tags: Toto From php and curl , I use this :

$url = 'http://localhost:12080/send'; $payload = json_encode([ "from" => $emailData['from'], "to" => $emailData['to'], "subject" => $emailData['subject'], "text" => $emailData['text'], "html" => $emailData['html'], "headers"=>'[{"X-Tags" : "Toto" }]' "attachments" => $emailData['attachments'] ]);

But, impossible to get this headers with Hook ( 'message:headers', 'message:store' ...)
Don t understand how get this Tags

Did I miss something? Thanks à lot !

louis-lau commented 3 months ago

Are you looking for the api:mail hook? The hooks you mentioned are for SMTP.

florentjb commented 3 months ago

thanks, but this hook return only :

{"from":"xxxt","to":["xxx"], "id":"18e7a638e4c000f68b", "interface":"api", "origin":false, "transtype":"HTTP", "time":1711450328652, "user":false}

louis-lau commented 3 months ago

Ah I see, sorry didn't know that. What's your usecase for checking headers when a message is submitted through the api? Surely you control the application doing it?

florentjb commented 3 months ago

it is very common to put additional tags in emails, for more detailed statistical purposes

louis-lau commented 3 months ago

I see, so like for statistics you're counting in a zonemta plugin? Doesn't seem possible right now when submitting through the api. If I were you, I'd either do the statistics counting in my (php) app or use smtp to submit it to zonemta.

florentjb commented 3 months ago

I will follow your advice to switch to SMTP ! thanks ;) Maybe a futur feature ? ;)