At the end of the two years, the participants' survival rates were compared to their personality scores, and hostility could be accurately used to predict someone's chance of dying of a repeat heart attack.
The researchers, writing in the European Journal of Cardiovascular Nursing, said "someone's character could impact the heart through both behavioural and psychological mechanisms.
"Hostile individuals have increased clotting times, higher adrenaline levels, above-normal cholesterol and triglyceride levels, and increased cardiac reactivity," they said.
"These known inflammatory factors may initiate cardiac events and increase poor clinical outcomes."
People with a positive outlook also exercise more, eat better and are less likely to consume alcohol.
Being optimistic also reduces stress and anxiety hormones, which can raise blood pressure and place a burden on the heart.
Study author Tracey Vitori of the University of Tennessee, Knoxville, said: "Hostility is a personality trait that includes being sarcastic, cynical, resentful, impatient or irritable.
"It's not just a one-off occurrence but characterises how a person interacts with people.
"We know that taking control of lifestyle habits improves the outlook for heart attack patients and our study suggests that improving hostile behaviours could also be a positive move."