According to Sophia's IMDB page:
"Carlo Ponti obtained a Mexican divorce from his first wife and married Sophia by proxy, while she was in Hollywood, filming Houseboat (1958) - and dating co-star Cary Grant (17 September 1957)."
On Cary's IMDB page:
"Often spoke of his relationship with Sophia Loren as one of the most passionate romances in his life."
"Fell madly in love with Sophia Loren while filming The Pride and the Passion (1957), despite the fact that he was married to actress Betsy Drake. However, Loren was seriously involved with producer Carlo Ponti, and her passion fizzled when the film wrapped."
"When Sophia Loren visited Los Angeles during the filming of "An Affair to Remember (1957)_, Grant inundated her with dozens of phone calls and hundreds of flowers - even though she had called the affair off."
"Initally accepted his role in Houseboat (1958) because he was dating Sophia Loren, whom he was madly in love with. After she went and married someone else, Cary, heartbroken, wanted to back out. He couldn't, but the director made sure the production was a smooth one."