You can resign via email, but a written letter is also recommended. An email can be seen as less formal than a written letter, so it's a good idea to include a brief email with a written letter attached.