To set From Address for sending emails using Apex, you have to set Organization-Wide Email Address and use setOrgWideEmailAddressId.
1. Go to Email Administration –> Organization-Wide Addresses.
2. Click “Add” button.
3. Enter the information and click “Save” button.
4. Go to the email entered. You would have received an email from Salesforce. Confirm it to verify the email.
5. Go to Developer Console and use the below Query.
SELECT Id, Address, DisplayName
FROM OrgWideEmailAddress
6. Store the Id in a Custom Label.
Sample Code:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setOrgWideEmailAddressId( System.label.OrgWideEmail );