Search code examples
emailnsis

How to send email within an NSIS installer?


Background:
For our software product (web application) clients will need to request a license from us before installing it.

We would need to check if they are a paying client (a manual process at the moment).
I need the ability for one of the initial steps of my installer to be let user request license via a custom page in the NSIS installer.
They would put in some mandatory fields and then this would get fired off in an email.
Ideally, NSIS would let them know that the email had successfully been sent.

They would then exit the wizard, but when we verify who they are and send them a serial (few days later), they can run installer again, and there would be an option to enter the serial, allowing them to progress to the next screen.

Ideally, the custom page will look something like this.

Question:
It is the emailing bit that I am currently stumped on. I have not seen any plugins to do this.

How can I send an email from a custom page in NSIS?
- I imagine there might be a couple of approaches?


Solution

  • Probably best way to send emails is to use external application. You can develop simple application in C/C++/C# if you have some programming skills, but there exist many apps for this purpose, e.g try this one called bmail: http://www.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm

    C:\>mail -s smtp.server -t cpeacock@max -f root@neptune -h -a "Subject e.g. Fatal Error" 
        -b "Body of message e.g. Fatal Error occurred in cgi script, secure.cgi"
    

    Simply use nsExec plugin to call this .exe with your desired parameters.

    Alternatively create.bat file with appropriate parameters, unpack it to $PLUGINS directory together with bmail.exe and launch the .bat using ExecWait command from NSIS.

    For creating custom page try this tool for NSIS: http://www.graphical-installer.com - it allows you to create skinned installer with custom page you need.