views:

155

answers:

1

What is the best way to send email from a Firefox extension? I can't just execute a mailto: link, because I need an attachment (actually, I really need a specific MIME-encoding, so I'd like full control of my headers).

Worst-case I can speak SMTP to the user's SMTP server I guess... is there a raw socket request ability in Firefox?

+1  A: 

Use a web-mailer - set up a script on a web server somewhere and POST a request to it (possibly with authorization), and it'll make an e-mail from it. FF is a browser - use that functionality, and have a server-side script do the heavy lifting.

For the server part, I'd go with PhpMailer, but any mailer script would do.


Manipulating raw sockets from a browser sounds tricky (not to mention platform-dependent); on most systems, you need root/Administrator privileges to do that); also, many ISPs block outgoing SMTP traffic (botnet prevention): SMTP traffic going to a different server than the ISP's SMTP host will get dropped in such case. (e.g. "drop traffic on port 25 to any host except smtp.someisp.example")

As you pointed out, the user has the ISP's SMTP server set up in their mail client, BUT this data is not accessible from inside Firefox; and snooping around in other apps' settings will get your extension flagged as "spyware" (also, how do you find out which mail client is the correct one? My system had two mail clients preinstalled, yet I'm using a different one).

Piskvor
I meant connecting to the SMTP server for the user's email... clearly their ISP can't be blocking it since that's how their email client would send mail, yes?That said, this solution may work out. The only problem with it is that my host would need a giant email send limit (assuming the extension got popular at all)
singpolyma
@singpolyma: How do you find out which mail client the user has? And then, how do you get the SMTP settings out of the mail client's settings? E.g. Thunderbird, Opera, Outlook, Outlook Express, Evolution; each has a completely different way of storing the SMTP servers and settings. Also, if there's some authentication at the SMTP server (quite common), do you pick the user's name and password from the settings?
Piskvor
@singpolyma: Also, on some machines, the users don't even *have* a mail client set up, precisely because of the SMTP mess, and they use a web interface (e.g. for gmail).
Piskvor