I have this class for sending email with android
public class SendMailTask extends AsyncTask {
private ProgressDialog statusDialog;
private Activity
Change below code
new SendMailTask(MainActivity.this).execute(fromEmail,
fromPassword, toEmailList, emailSubject, emailBody);
To
new SendMailTask(getActivity()).execute(fromEmail,
fromPassword, toEmailList, emailSubject, emailBody);
For more details you can check below link.
Accessing the Activity from a Fragment