Both are correct.
In a dialogue, a pause can be used for effect, putting emphasis on the greeting, eg:
Hello, Mr. Black.
"Hello" is said first, then a pause, then the name.
Normally, people would say: Hello Mr. Black.
Without any pauses in their speech.
When writing a letter or email, it is quite common to do this: Hello
Mr. Black, Bla bla bla... Or in a more formal situation: Dear Mr. Black, Bla bla bla...
It is uncommon to put a comma before the title even in an informal email salutation (though quite acceptable), but it would never be done in a formal letter/email.
english.stackexchange.com/users/140/Vincent McNabb
Not placing a comma before a proper noun will change the object of the sentence.
These examples should explain: Let's eat, John!
(Correct)
Let's eat John!
(This means you'd like to eat John.)
Let's eat, everybody.
(Correct)
Let's eat everybody
(This means you'd like to eat everybody.)
english.stackexchange.com/users/53069/Peter Cornish
When I read Hello, Mr. Black
I find that I mentally need there to be a comma at the end as well, or perhaps a full stop.
Hello, Mr. Black, how are you today?
Hello, Mr. Black.
And the result is that the name is emphasized.
Whether you want to do this or not depends on the circumstances, but for letter writing this is usually not what you want.
If you simply want a standard greeting put the comma after the name (or a full stop if the greeting is your whole sentence).
Hello Mr. Black.
Hello
Mr. Black, how are you today?
english.stackexchange.com/users/380/Mr. Shiny and New 安宇
In formal writing you would put a comma after greetings: "Hello, Mark."
In emails and informal writing, it doesn't make a whole lot of difference.
I, for one, feel self-conscious about using commas like that in emails; it seems too formal.
english.stackexchange.com/users/2303/Robusto
In the specific case of the opening salutation I would not insert a comma between the greeting and the name if a comma came after the name, but I would if some other punctuation followed the name.
The following examples all "look correct" to me: "
Hi Mark, how are you?"
"Hi, Mark.
How are you?"
"Hello Mark, what's up?"
"Hello, Mark!
What's up?
"
But the "Hi, Mark, how have you been?"
example that you gave looks over-punctuated to me.
english.stackexchange.com/users/2490/Hellion
The title of the question said “in a letter” in which case you would be better sticking to: Dear Mr. Black,
How are you today?
(The the rest of the letter follows.)
Other forms may be grammatically correct and certainly not a problem in an email.
But for a the more traditional context of a letter, I think your safest bet is this one.
english.stackexchange.com/users/19071/Philip Jones
You need to place a comma between the salutation and the name of the person addressed.
"
Hello, Mr. Black.
How are you today?"
english.stackexchange.com/users/None/
Sometimes I see a comma  after  the proper name:   Hello Mr. Black,  In order to give you....   But my native language is not English and I think that the comma in this phrase should be placed  before  the proper name:    Hello, Mr. Black.  In order to give you....   What is the correct punctuation in English?
Where should the comma be placed in the salutation of a letter?
english.stackexchange.com
<grammar><punctuation><commas><proper-nouns>
english.stackexchange.com/questions/1025
english.stackexchange.com/users/81/igor
It is considered that putting the comma before or after a persons name in a salutation is correct. There should be a comma after a greeting, but it may not be correct to place another comma after the person's name. In fact, it may be best not to place a comma before the name if a comma already follows the name. There is no hard and fast rule but in salutations it is much more common to put the comma only after the name.
It is considered that putting the comma before or after a persons name in a salutation is correct. There should be a comma after a greeting, but it may not be correct to place another comma after the person's name. In fact, it may be best not to place a comma before the name if a comma already follows the name. Some suggest that in case of the opening salutation you should not insert a comma between the greeting and the name if a comma came after the name, but only if some other punctuation followed the name.  Others say that you need to place a comma between the salutation and the name of the person addressed. The title of the question said “in a letter” in which case you would be better sticking to:   Dear Mr. Black,       
In a letter, it would be best to use "Dear Mr. Black,". It is uncommon to put a comma before the title even in an informal email salutation (though quite acceptable), but it would never be done in a formal letter/email. The answer to this question appears to be subjective and there does not seem to be a correct answer. Some people will advocate avoiding commas before names whilst other may feel it is required. Other people may feel that a comma needs to follow the name. In any case, it is unlikely to have much importance which you choose.
Both forms are correct but it is much less common to place the comma before the name. Not placing a comma before a proper noun can change the meaning. If commas are placed before and after the name it will emphasise the name as it is unusual In formal writing the comma comes after but in emails it does not matter. I would insert a comma before only if punctuation came after the name. For letters you should put the comma only after the name.
Some suggest that in case of the opening salutation you should not insert a comma between the greeting and the name if a comma came after the name, but only if some other punctuation followed the name.  Others say that you need to place a comma between the salutation and the name of the person addressed. The title of the question said “in a letter” in which case you would be better sticking to:   Dear Mr. Black,       
Both styles of punctuation are considered correct and it is unlikely to be very important which you choose. Many people would prefer to avoid putting a comma before a name in a salutation. Some people feel that a name must be placed before a name after a salutation. Some people advocate putting a comma after the name in an opening salutation.