Can a two-sample t-test be used if the samples have different variances?
If you have unequal variances, you wouldn't use the student's t-test, which assumes equal variances. You would use the Welch's t-test, which does not assume your variances are equal and is a variation of the student's t-test.
This test still assumes your data is distributed normally but the equation differs from that of a student's t-test. You use the Welch–Satterthwaite equation to calculated the degrees of freedom.
You can read bout the Welch's t-test in detail here.
If your data is not distributed normally or the variances between your two samples is very large, it may be worth considering a Mann-Whitney U-Test instead. This test is nonparametric.