New York Republican Lewis Lehrman mailed out 3 million letters during the last week of the campaign before the Nov. 2 election that almost made him governor, according to the campaign manager for the winner, Democrat Mario Cuomo.

Upstate independents with Republican leanings got one letter; downstate independents leaning Democratic received another. Jewish voters were sent a letter saying, "Lew Lehrman speaks our language." Catholic voters got one saying Cuomo opposes tuition tax credits and "favors taxpayer funding for unrestricted abortion on demand." Still another letter said Cuomo's election would be "an open invitation to rape, murder and mugging."

Lehrman, who had been trailing by 8 to 12 percentage points in campaign opinion polls, came within 3 points of upsetting Cuomo. The letters he sent out during the final week and the way they were targeted to voting groups are a textbook example of the computer-tape politics of the future.

"All things being equal those letters would have beaten us," said William Haddad, Cuomo's campaign manager, who added that Lehrman's $1 million-plus direct mail effort, the most extensive and sophisticated ever used statewide in New York, carries an awesome political message.

"Lehrman opened a Pandora's Box which Democrats aren't ready for. We're going to get it right between our eyes in 1984 unless we prepare ourselves," he contended. "To me, it's the most fearsome thing I've seen in politics. It could create a situation in 1984 that is very 1984ish."

Both Republicans and Democrats in races around the country turned to computers and mailboxes more than ever before this fall, flooding homes with millions of controversial and often unwanted letters designed, as one strategist put it, "to make the blood boil."

John McIlquham, assistant publisher of Friday Report, a newsletter for the direct mail industry, estimated that a record $100 million was spent during the election campaign on direct mail. This would be enough to send 4 1/2 letters to every household in America. He said $10 million was spent on a gun control referendum in California alone.

In Northern Virginia, GOP campaign aides believe that "the prison letter" and "the sewer letter" may have won the election for Rep. Stan Parris (R-Va.). The letters, part of a sophisticated direct mail that targeted special messages to 53 different groups of voters, went to 50,500 homes in three neighborhoods. Parris carried the neighborhoods, which he lost two years ago, by a large enough margin to give him a razor-thin victory over Democrat Herbert Harris.

In New Mexico, Democrats credit a pilot program targeted at 100,000 voters with helping the party win the governorship and a Senate seat and sweep state constitutional offices. Each targeted voter received two pieces of mail and at least three phone calls in October in the program, which Democrats hope to duplicate nationally in 1984.

In California, Hugh Schwartz, pollster for Democratic gubernatorial nominee Tom Bradley, said direct mail "was as important as race" in Bradley's narrow loss to Republican George Deukmejian. One letter accused Bradley of cutting the size of the Los Angeles police force; another charged that he opposed Bible study in homes; others mentioned his support of gun control.

But the letter with the biggest impact in the view of strategists in both parties was one sent along with absentee ballots to "double Republican households," those with two GOP voters in the family. Deukmejian's absentee vote soared, Schwartz said. In San Francisco, he trailed by more than 2 to 1 among people who went to the polls, yet won by 3 to 2 among absentee voters.

In 11 states with critical Senate races, every registered Republican voter received a personally addressed "election-gram" from Ronald Reagan on election eve urging them "to vote and to vote Republican -- for the sake of everything you want -- or risk losing everything we have . . . . Your vote could well make an historic difference."

Politicians have been using the mails to reach the hearts and pocketbooks of voters for years. What happened in 1982 was that politicians had enough money to use it on a larger scale than ever before, and political parties took increasing advantage of a special nonprofit postal rate that enables them to mail for as little as 3.9 cents per letter.

They used it not only to raise money, but to direct special messages to different groups of voters. When early October polls found that lethargy among GOP voters endangered party candidates, the Republican Senatorial Campaign Committee decided to send the Reagan "election-gram" to eight million voters at a cost of $1.3 million.

Democrats didn't have money for a national direct mail campaign. Interviews with dozens of experts indicate Republicans also generally outmailed them in state and local races. Lehrman, for example, sent out 11 separate mass mailings in New York, Cuomo only one. The California Democratic Party spent about $800,000 on direct mail; California Republicans about $1 million.

What bothers some politicians and excites others is that direct mail enables a candidate to send a special message to one group of voters and another to another group. "It was effective for us largely because of the way you could target your message," said Lehrman's press secretary John Buckley.

"What you're able to do with direct mail is target almost every fear, prejudice and concern under the sun," said Cuomo campaign manager Haddad. "We've learned to take television ads with a grain of salt, but people still take letters seriously."

One of the most sophisticated such efforts in the country took place in the Virginia congressional district directly across the Potomac River from the U.S. Capitol where former congressman Harris challenged incumbent Republican Parris.

Parris sent out 1.3 million copies of 53 different letters. One went to firemen, another to policemen, another to lawyers, another to teachers. A letter to Alexandria voters said Parris obtained money to repair the deteriorating Woodrow Wilson bridge.

A letter sent by the National Rifle Association the weekend before the election called Parris "a proven friend of the sportsman" and alleged that Harris as a congressman "compiled one of the worst anti-gun, anti-hunter records in Congress."

Another sent by the National Association of Realtors alleged that "employment would increase in Virginia by 34,380 new jobs by 1983 if Stan Parris' votes became law and employment would have decreased in 1980 by 25,480 jobs if Herb Harris' votes had become law." It was signed with a good Virginia name, Thomas Jefferson III, trustee of the realtors' state political action committee.

But the Parris campaign believes it was the "sewer" letter and the "prison" letter that turned the trick for the congressman. Locked in a dead heat with Harris the week before the election, Parris sent the prison letter to 50,000 homes in the Mount Vernon and Lee districts of Fairfax County, areas he lost by 924 votes in 1980.

The prison letter was aimed at refuting claims by Gov. Charles S. Robb that he had no plans to build a prison in southern Fairfax County. It reprinted the text of a letter Robb had written to President Reagan asking that a parcel of land at Fort Belvoir be turned over to Virginia for use as a prison.

"I will protect you from this ill conceived proposal," Parris wrote. "Liberal Herb Harris does not share my determination on this matter." Harris tried to reply with a letter of his own, claiming Parris had distorted his position.

But the damage was already done. Parris carried the Mount Vernon and Lee districts for the first time in his career by 1,101 votes.

The sewer letter went out Oct. 27, the same day as the prison letter, to 500 homes in the tiny community of Rippon Landing, plagued until recently by odors from a treatment plant. In it, Parris claimed credit for getting a federal grant to stop the odor. He carried the area, which he has traditionally lost, by 48 votes.

If the vote totals in the areas where the sewer and prison letters went were reversed, Harris would have won. "We think the letters jumped us the 1 or 2 percent we needed to win," said Parris press secretary Dick Ligget. "They were dynamite. We think we've written a new textbook on how to run a sophisticated direct mail campaign."