At present train travel between Spain and Portugal is difficult as there are only 4 trains a day between the two countries. This will all change in a few years when the new TGV style high speed train network enters service.
You trip will require at least two changes:
Service as follows:
Santander 16:55
Valladolid 21:07 (Mondays to Saturdays).
Valladolid 03:20 (Sud Express)
Coimbra-B 08:49
Coimbra-B 09:29
Porto 10:39
For more information see the sites of:
Renfe - Spanish Railways - renfe.es
CP - Portuguese Railways - cp.pt