• Suppose you have email profile name, please run this qurey under msdb:

    select a.Name Mail_Profile_Name, s.port

    from dbo.sysmail_account a INNER JOIN dbo.sysmail_server s ON a.account_id = s.account_id

    WHERE a.Name ='Your Mail Profile Name'