views:

173

answers:

3

I need to be able to display ads on email forwarded through a server (preferably postfix) based on the demographic information of the recipient. Basically a message will arrive for [email protected] and be forwarded to [email protected] with a small advertisement at the bottom.

I would like to use postfix because it appears to be able to use mysql data for various tasks, which would be beneficial so that the system could be controlled by a web app that feeds the database.

I'd prefer to use OpenX for the ad server due to targetting channels (used to select ads based on demographic information), the ability to do text ads as well as email zones, and the ability to run it locally. Other ad servers that are better suited to this problem are acceptable, of course.

The core of the problem, as I see it, is being able to write something at the bottom of any given email message. Of course html messages make this even trickier, but I'd settle for having a solution that works for plain text and work up from there.

Commercial software is an option as well, but a few days of intermittent searching hasn't turned anything up.

+3  A: 

Somehow, I find myself utterly uninterested in aiding you.

edit

It's a really bad idea and you shouldn't do it at all.

Steven Sudit
care to elaborate on that?
Ty W
He means that what you're doing is basically reprehensible to most people
Jherico
+1 here... It's a valid question so I can't justify a downvote for it (as much as I want to).
Austin Salonen
I'd do a +1 for the laugh, and a -1 for 'this it not helpful', but the system won't let me do both at once ;)
Henrik Opel
It's a service people sign up for with full knowledge of what they're going to get. I wouldn't sign up for it personally, but that doesn't change the fact that I need to build it. Please note that the ads are viewed by the person signing up, not on the email they send out. Roughly similar in ethics to Google serving ads to you on GMail.
Ty W
What Jherico said. You might as well ask "How can I send out large quantities of unsolicited email offering viagra at low prices?"
Steven Sudit
Henrik, I believe the whole point here is that I do not wish to be helpful.
Steven Sudit
@Steven: If you don't wish to be helpful, you shouldn't even post an answer like this. Please remove this and post it as a comment instead.
gnovice
I believe it has more value in its current form, particularly as removing it would lose all of the associated comments.
Steven Sudit
I believe your answer has no proper value to SO as it is now. The Q is valid and you're sending a wrong signal. If you disagree with the topic, don't reply but flag it instead so a moderator can take a look. But your answer is suggesting this would be some kind of misuse or illegal scheme. I consider it even a bit offensive and defamation.
Workshop Alex
My answer is suggesting that I consider it a bad idea and do not wish to aid it. I am not a lawyer, so I am not offering legal advice.
Steven Sudit
True, but the suggestion that the question is asked in bad faith is raised by your answer. Besides, while the technique could be used for something bad, it would be easily detectable, especially if he used something commercial for this. Besides, he wants this for his own server so he's free to determine what it does, right?
Workshop Alex
And I'm free to be uninterested in helping him modify email to insert advertisements, just as I'm free to state this fact here.
Steven Sudit
You are free to voice your opinion but SO is a place for answers, not opinions.
Workshop Alex
The correct answer to "How do I do something incredibly stupid and offensive?" is "Don't do that". You have my answer.
Steven Sudit
Then make THAT your answer. Now your answer is as stupid as the question.
Workshop Alex
Thanks! Your answer is better now! :-)
Workshop Alex
+5  A: 

Simply writing something to the bottom of the email message will fail miserably in a LOT of cases, particularly with HTML email encapsulated in a MIME multipart message (or anything else in a MIME multipart message) because anything after the last MIME section marker is explicitly supposed to be ignored by any MIME parser. If you want your app to work it needs to

  • determine if the target message is a MIME message other than TEXT/PLAIN
    • If it is not, append your text only ad at the end and you're done
  • if it is, determine if its multipart
    • if not, then you need to determine the content type of the whole message
      • If the content type is HTML then you can attempt to insert your ad HTML somewhere appropriate. This will be very hit or miss since you have no idea what the HTML layout will be like.
      • if the content type is anything OTHER than HTML (or maybe RTF), you're best off not touching the message.
  • If the message is multipart, determine the subtype
    • if its 'mixed', then you need to determine which part if any is the primary readable content, and then modify that portion as if it were the whole message based on the above rules
    • If its 'alternative' then you need to find ALL the readable portions and modify each of them in turn according to the above rules

Finally, and most importantly

  • Be prepared for the massive ill will you will receive from everyone who gets mail routed through your server.
Jherico
Unfortunately this is exactly my area of expertise so I feel compelled to give knowledge where its asked for. I feel like I'm publishing plans for a nuke.
Jherico
this isn't an evil scheme to send ads to everyone passing through the server. it's only for people who signed up for email forwarding accounts ([email protected] => [email protected]). Is serving an ad at the bottom of a message to the user signing up for the forwarding service really that unethical?
Ty W
Jherico, it is mine as well, but I do not share your compulsion.
Steven Sudit
At any rate I appreciate the response, and your logic in the answer matches up exactly with what I was hoping to be able to accomplish... I'm just stuck at the part where I manipulate the message before the server forwards it out... I haven't written anything before that interfaces with a mail server. The only software I saw that did anything similar is <a href="http://www.pldaniels.com/altermime/">alterMIME</a> and that appears to allow just a static disclaimer.
Ty W
We have only your word that this is voluntary Ty. And it seems a little weird that you're planning on building a service but need advice on the most fundamental aspect of it.
Jherico
IF what you want is help on how to configure Postfix to do this, you should be asking on server fault, not stack overflow. That's a app config problem, not a programming problem.
Jherico
As for ethics, you'll find that most people who have been using the net longer than 10 years are very touchy about email, which most of us have seen go from an incredibly useful channel for rapid asynchronous communication to 'shit faucet'.
Jherico
Fair enough, but neither I nor the company that employs me engage in unethical business practices. We're still at the stage where we're feeling out the potential project before things are signed, and none of us had been able to dig up anything on the net on how to interface with the mail server to do what we needed to do... so I turned here as a resource that has served me well in the past. I apologize if I've ruffled any feathers and thank you for your time.
Ty W
Perhaps you might wish to consider the strength of the negative reaction here before continuing in your business plans. I believe the phrase "shit faucet" speaks for itself.
Steven Sudit
A: 

Let me see... People sign up for your service, which I assume is free. They provide you their real email address and in return you provide them a different email address which they can use to e.g. subscribe to mailinglists and for other services. And maybe some spamfilter functionality? That sounds like a legit service to me, especially if you only provide the ads to the person who subscribed. I do wonder if you'd get many subscriptions, though, since many people can just as easy use a Google, Yahoo or Hotmail account for these purposes. So, what is the added value those subscribers will get?

Anyway, you would need to modify existing emails, which is a bit complex when they are HTML mails or if they're digitally signed. (Especially in the latter case, you would actually block the recipient from receiving those emails, since their email system would detect that the email has been tampered with. You might also be at risk of possible legal problems, although I don't think there's anything illegal as long as the recipient agrees with the terms of your service.

Workshop Alex
The value added on this sort of thing is the vanity domain and the ability to switch real email providers without having to change your publicly visible address.
Jherico
This has been tried as a business plan before. PoBox.com, Mail.com, and Bigfoot.com are three examples. It turns out not to be a great business model, and has been made increasingly irrelevant by the existence of high-quality web mail, such as GMail.
Steven Sudit