In a bid to reverse the negative repercussion of the Carlos Danger sexting scandal on his campaign to become New York City mayor, former Congressman Anthony Weiner blamed his behaviour on his troubled marriage to wife Huma Abedin.

Abedin, ironically once served as aide to former State Secretary Hillary Clinton, whose husband, former President Bill Clinton, once was almost impeached because of his sexual dalliances with White House intern Monica Lewinsky.

"Sending those embarrassing messages to women online, whom I never met, was a personal failing that was hurtful to my wife and a part of my life that Huma and I have put behind us," The New York Post quoted Mr Weiner's letter to political followers.

The candidate's online behaviour was exposed by gossip Web site the Dirty, which said that using the alias Carlos Danger, Mr Weiner sent sexually explicit chat messages to women some of which were sent after he resigned from Congress in 2011 over the same problem.

Another Web site, Slate.com, which featured the portal that Mr Weiner used to generate the name Carlos Danger, said that the ex-congressman used a Yahoo account to email photos of his penis.

Among the recipients of these lewd images and message was a 22-year-old Indiana woman, named by the New York Post as Sydney Leathers, a progressive activist.

Mr Weiner has neither confirmed nor denied that claim by Slate, but he admitted most of the sexting he did.

"These things I did, as you have read in the papers, didn't happen once. It was a terrible mistake that I unfortunately returned to during a rough time in our marriage. After a lot of reflection, some professional help, and a general reorientation of my life, Huma has given me a second chance. I will never stop being grateful for that," he added.

The Dirty has published so far two of Mr Weiner's penis photos, including this selfie shot.

The mayoral candidate insisted that all the dirt about his online behaviour is part of a powerful campaign to prevent him from running, even as he insisted he no longer sends sext messages.

"People who know me are still going to vote for me," Mr Weiner insisted.

"I have posited this whole campaign on a bet, and that is that, at the end of the day, citizens are more interested in the challenge they face in their lives than in anything that I have done, embarrassing, in my past," he told reporters as he left his Manhattan home.

A Pew Research Center study said Mr Weiner's online behaviour is shared by adult mobile phone owners, 6 per cent of whom admitted sexting, while another 15 per cent acknowledged receiving lewd messages and images.

However, another report said it is not only the ex-congressman who uses the unlucky name, but there is a real Carlos Danger, who is not into sexting.