Image copyright Reuters

A UPS employee who killed three colleagues at a San Francisco depot of the postal firm before turning the gun on himself has been named.

Jimmy Lam, 38, killed Wayne Chan, 56, Benson Louie, 50, and 46-year-old Michael Lefiti, in the attack, the city medical examiner said.

Two other employees were shot at the four-storey facility, but survived.

The attacker, who authorities said was armed with an "assault pistol", shot himself as police closed in.

United Parcel Service (UPS) spokesman Steve Gaut told AP news agency an employee opened fire on colleagues before drivers were sent out for deliveries.

Teamsters Union official Joseph Cilia told AP news agency that Lam had filed a grievance complaining he was working excessive overtime.

Mr Cilia said: "I never knew Jimmy to not get along with people. Jimmy wasn't a big complainer."

Image copyright Getty Images Image caption UPS employees are escorted from the depot following the attack

Investigators were still working to determine a motive, but authorities said the incident was not thought to be connected to terrorism.

San Francisco police Assistant Chief Toney Chaplin said when officers encountered the armed suspect in the building he "put the gun to his head and discharged the weapon".

San Francisco Mayor Ed Lee called the shooting a "senseless act of violence".

UPS has said it was "saddened and deeply concerned" about the shooting, which the company said involved six employees.

More on US mass shootings - Could this be a way to stop them?