Sending Email in ASP.NET
I set the from address as
System.Net.Mail.MailAddress("testemail@example.com",开发者_运维百科 "TESTEMAIL")
Knowing that the first parameter is the address and the second is the display name, when I tried to send an email, I got
From: TESTEMAIL <testemail@example.com>
How can I do this without displaying
<testemail@example.com>?
I just want to see
From: TESTEMAIL
There are a couple bad assumptions here:
Not everyone's e-mail client works as yours does. Some will already display only "TESTEMAIL", just like you want. Others will ignore "TESTEMAIL" entirely and only display "testemail@example.com", and there's nothing you can do about it. Many allow the user to choose how the user will see your name. None allow you, the sender, to override the user's preference.
I know you probably have messages come in to your own inbox this way, but that will happen only for addresses with e-mail domains that your e-mail client has chosen to trust, and there is nothing you can do to make other's e-mail clients trust your domain.
That's only if your messages make it to their destination in the first place. If you send messages yourself, they stand a good chance of being filtered as spam somewhere along the way. You almost always need to use an established, reputable, service when sending e-mail from a web site.
Of course, those are moot if you're working on an intranet site sending mail entirely within your own organization... but in that case, "TESTEMAIL" vs "testemail@example.com" hardly matters.
You cannot send an email without specifying an email.
What you can do is specify a display name the way you are already doing, but how it will be displayed by the client is a call of the client, not yours.
精彩评论