Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a custom variable to an email header already within a gmail inbox

this may seem odd but I was wondering if it was possible to add custom header details to emails already in an inbox. Like lets say I wish to add in the Header of the email something like - myvariable = myvalue and then be able to query it somehow. I'm looking at code from Iloha mail and most of the details like subject and from recieved etc are in the headers and you can search through them. SO is it possible to add my own custom variable to an email header and query it in the same way? How can it be done using php?

EDIT ====================

Thanks I know how you can modify the headers of sent messages plus also query for custom variables in message headers however in this case I want to know if it would be possible to add a custom variable in a recieved message already in my inbox. Actually let me define the situation here.

I'm working on a google apps solution which requires maintaining references to emails. Basically the application is as such that when an email comes in - we create an order from that email and wish to maintain a reference to that EXACT email by some kind of identifier which would enable us to identify that email.

The fact is that we don't want to download the emails in a database and maintain a separate store as we would want to keep all the emailing on GMAIL. We just need:

A way to be able to 'link' to a specific email permanently - the UID is just a sequence number and not very reliable. We couldn't find any property of emails that could function as a unique ID or primary key and so we thought if we could instead generate a key on our end and store it in a custom variable on the email itself. However it seems unfortunately that there isn't a way to manipulate headers of an already existing email.

:( is there any solution to this problem I could use any IDEA !

like image 913
Ali Avatar asked Mar 24 '10 08:03

Ali


People also ask

How do I create a custom header in Gmail?

Click "Settings" > "Appearance" on the left menu. Scroll down to "Email Headers and Footers." Click the "HTML Header" dropdown and select either HTML Header or Text header. Enter the header and footer information into the appropriate box.

Can you edit an email header?

An email's header and footer information can be edited directly within your email draft.

How do I do an advanced search in Gmail?

Gmail now has an advanced search drop down panel (click the arrow on the right of the search box) with fields that help you search and the ability to choose a label to search within.


1 Answers

Yes you can add your own headers when sending an email...

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'myvariables: myvalue';

mail($to, $subject, $message, $headers);
?> 

I doubt you can modify the existing emails headers unless they are stored in a database or something rather than just being retrieved from your POP/IMAP server.

like image 158
fire Avatar answered Sep 24 '22 13:09

fire