Definition: electric flux
Consider a horizontal surface such as the one shown below with an upward normal $d\overrightarrow{A}$. Let $\overrightarrow{E}$ denote an electric field that makes an angle $\theta $ with the horizontal surface and let $E_{\parallel }$ and $E_{\bot }$ denotes its parallel and perpendicular components respectively.
d{\mathrm{\Phi }}_E=\overrightarrow{E}\cdot d\overrightarrow{A}=E{\mathrm{cos} \left(\theta \right)\ }dA
Thus, to account for the entire surface area, we integrate $d{\mathrm{\Phi }}_E$ over the entire area $A$ which yields
\boxed{{\mathrm{\Phi }}_E=\iint_A{\overrightarrow{E}\cdot d\overrightarrow{A}}=\iint_A{Ecos\left(\theta \right)dA}\ \ \ \ \ \ \left(N\cdot m^2/C\right)}
Special case: if the electric field is constant in magnitude and direction over the entire surface, then the quantity $Ecos\left(\theta \right)$ is constant over the entire surface and can be pulled out of the integral to yield
\boxed{{\mathrm{\Phi }}_E=\iint_A{Ecos\left(\theta \right)dA}=Ecos\left(\theta \right)\iint_A{dA}=EAcos\left(\theta \right)}
where $\displaystyle{\iint_A{dA}=A}$ by definition. As a manner of making the notation compact, the electric flux is then often written as the following dot product:
\boxed{{\mathrm{\Phi }}_E=\overrightarrow{E}\cdot \overrightarrow{A}}
Note: if the electric field $\overrightarrow{E}$ is spatially uniform (the same everywhere), then the above condition is automatically satisfied.
Sign of the electric flux:
The electric field is everywhere perpendicular to the surface: no field lines traverse the surface and the net flux is zero.
The number of field lines that enter the closed surface is equal to the number of field lines that exit the surface. The net flux is then zero even though the gravitational field does traverse the closed surface.