Hey there marianogx,
Welcome to Apple Support Communities.
Does the issue with Safari unexpectedly opening links from Mail in portrait mode only occur with specific links?
The article linked below provides troubleshooting suggestions that’ll resolve most issues with apps from the App Store, but they can also be used to resolve issues with apps that came with your iPhone, like Safari.
iOS: An app you installed unexpectedly quits, stops responding, or won’t open - Apple Support
Restart the app
Close the app and open it again.
Restart your device
Turn the device off and on.
Update your device software and your apps
Update your device to the latest version of iOS.
Cheers,
-Jason