473,225 Members | 1,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

how to send mail via AUTHENTICATED smtp account?

RN
I am tired of sending mail from the built-in SMTP service for so many
reasons (errors are nondescriptive in the event log, it doesn't let me
control which IP address it sends from, and it identifies itself as the
computer name which is not in domain.com format, triggering spam filter
problems).

Instead, I want to have my code send through an SMTP server of a company
that we pay for mail service. But they require a username and password.
How do I use something other than "localhost" for the Smtp Server and how do
I pass the username and password?
Nov 19 '05 #1
3 2989
I recently hunted high and low for the same purpose. Here is what I found.
It is apparently undocumented, but has been working for me very well. The
whole trick is in the mail.Fields.Add lines:

System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
mail.To = eMailRecipients; //"Jo*****@Yahoo.com;Ja*****@Yahoo.com";
mail.From = "Me@MyDomain.com";
mail.Subject = "Hello World!";
mail.Body = messageToGo;
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
"MyFullUserNameHere"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
"MyPasswordHere"); //set your password here

System.Web.Mail.SmtpMail.SmtpServer = "Mail.YourDomain.com"; //your smtp
server goes here
System.Web.Mail.SmtpMail.Send( mail );

If someone else has a better way I'd like to know.

-Smithers

"RN" <re*************@please.com> wrote in message
news:Ju******************@twister.socal.rr.com...
I am tired of sending mail from the built-in SMTP service for so many
reasons (errors are nondescriptive in the event log, it doesn't let me
control which IP address it sends from, and it identifies itself as the
computer name which is not in domain.com format, triggering spam filter
problems).

Instead, I want to have my code send through an SMTP server of a company
that we pay for mail service. But they require a username and password.
How do I use something other than "localhost" for the Smtp Server and how
do
I pass the username and password?

Nov 19 '05 #2
RN
Thanks, I'm excited to try it.

Maybe you also know the answer to this very related question... Sometimes I
send from aliases that are mapped on the POP3 server if someone did reply.
For example, suppose I have a real account called sa***@domain.com, and
that's a real account that has a username and password that I can use in
your example. But often I will send mail from something else like
or************@domain.com . There's no account for this, but I have an
alias on the pop server that will map any incoming mail to order-receipts
over to the real sales account. Obviously I still need to send from
order-receipts, though. Using the SMTP server with IIS, this works fine.
Now that I'm going to send through a 3rd party mail server, I'm wondering
what will happen. Can I put anything I want in the mail.From field as long
as it is at the same domain?

Have you found out anything else, good or bad, about using this technique
compared to the regular IIS SMTP service?

Again, thanks very much. Yours was a perfect newsgroup reply!
"Smithers" <Ja*********@OnceOver.com> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
I recently hunted high and low for the same purpose. Here is what I found.
It is apparently undocumented, but has been working for me very well. The
whole trick is in the mail.Fields.Add lines:

System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
mail.To = eMailRecipients; //"Jo*****@Yahoo.com;Ja*****@Yahoo.com";
mail.From = "Me@MyDomain.com";
mail.Subject = "Hello World!";
mail.Body = messageToGo;
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenti
cate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername
", "MyFullUserNameHere"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword
", "MyPasswordHere"); //set your password here

System.Web.Mail.SmtpMail.SmtpServer = "Mail.YourDomain.com"; //your smtp
server goes here
System.Web.Mail.SmtpMail.Send( mail );

If someone else has a better way I'd like to know.

-Smithers

"RN" <re*************@please.com> wrote in message
news:Ju******************@twister.socal.rr.com...
I am tired of sending mail from the built-in SMTP service for so many
reasons (errors are nondescriptive in the event log, it doesn't let me
control which IP address it sends from, and it identifies itself as the
computer name which is not in domain.com format, triggering spam filter
problems).

Instead, I want to have my code send through an SMTP server of a company
that we pay for mail service. But they require a username and password.
How do I use something other than "localhost" for the Smtp Server and how do
I pass the username and password?


Nov 19 '05 #3
<<Yours was a perfect newsgroup reply>>
Is that like a "great golf shot?" (what other type of shot is there on a
golf course?)

<<Can I put anything I want in the mail.From field as long as it is at the
same domain?>>
AFAIK you can put anything you want in the mail.From field... doesn't even
have to be in the same domain. You could put "snoop@dog" in there if you
wanted to.

<<Now that I'm going to send through a 3rd party mail server, I'm wondering
what will happen>>
Your mail will go through as expected... as long as you use credentials that
are valid on the 3rd party mail server.

<<Have you found out anything else, good or bad>>
Nope - it works and that's as far as I got. I have work to do so I didn't
sit down and simultaneously try multiple approaches for the fun of it.

I'd like to hear from any others if they have any better way to do the same
thing *without* using CDO or some other mail component. It does

Those were great newsgroup questions!

HTH!
"RN" <re*************@please.com> wrote in message
news:j3*******************@twister.socal.rr.com...
Thanks, I'm excited to try it.

Maybe you also know the answer to this very related question... Sometimes
I
send from aliases that are mapped on the POP3 server if someone did reply.
For example, suppose I have a real account called sa***@domain.com, and
that's a real account that has a username and password that I can use in
your example. But often I will send mail from something else like
or************@domain.com . There's no account for this, but I have an
alias on the pop server that will map any incoming mail to order-receipts
over to the real sales account. Obviously I still need to send from
order-receipts, though. Using the SMTP server with IIS, this works fine.
Now that I'm going to send through a 3rd party mail server, I'm wondering
what will happen. Can I put anything I want in the mail.From field as
long
as it is at the same domain?

Have you found out anything else, good or bad, about using this technique
compared to the regular IIS SMTP service?

Again, thanks very much. Yours was a perfect newsgroup reply!
"Smithers" <Ja*********@OnceOver.com> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
I recently hunted high and low for the same purpose. Here is what I
found.
It is apparently undocumented, but has been working for me very well. The
whole trick is in the mail.Fields.Add lines:

System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
mail.To = eMailRecipients; //"Jo*****@Yahoo.com;Ja*****@Yahoo.com";
mail.From = "Me@MyDomain.com";
mail.Subject = "Hello World!";
mail.Body = messageToGo;

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenti
cate",
"1"); //basic authentication

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername
",
"MyFullUserNameHere"); //set your username here

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword
",
"MyPasswordHere"); //set your password here

System.Web.Mail.SmtpMail.SmtpServer = "Mail.YourDomain.com"; //your smtp
server goes here
System.Web.Mail.SmtpMail.Send( mail );

If someone else has a better way I'd like to know.

-Smithers

"RN" <re*************@please.com> wrote in message
news:Ju******************@twister.socal.rr.com...
>I am tired of sending mail from the built-in SMTP service for so many
> reasons (errors are nondescriptive in the event log, it doesn't let me
> control which IP address it sends from, and it identifies itself as the
> computer name which is not in domain.com format, triggering spam filter
> problems).
>
> Instead, I want to have my code send through an SMTP server of a
> company
> that we pay for mail service. But they require a username and
> password.
> How do I use something other than "localhost" for the Smtp Server and how > do
> I pass the username and password?
>
>



Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: oliu321 | last post by:
Hi, I am trying to write some codes to send emails through a SMTP server. I wrote a C++ version using pure socket programming and SMTP protocol, a VB version using CDO and a C# version using...
8
by: shapper | last post by:
Hello, I am trying to send an email using Asp.Net 2.0. I am getting the following error: System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: No such...
5
by: Sin Jeong-hun | last post by:
Hi. I would like to let users send bug reports or other messages to me. Maybe the easiest way to send e-mails from my application is just use the default e-mail agent by executing a link...
1
by: chaitanya02 | last post by:
Hi All, Well- this question might have appeared several times on this forum- but would appreciate your reply on this: I have a asp page, where customers login with some username and the pwd,...
3
by: BLUE | last post by:
I want to send an email from my web service. I do not want to act like an email client, giving credentials of an existing email account to send messages: I would like to send my mail directly to...
2
by: Bgreer5050 | last post by:
I posted a problem with sending email via smtp using Dot Net 2.0 I was told to look at adding authentication to my web.config file; I added the following: authenticationMode="SSL" I put...
7
by: John Drako | last post by:
Currently, I run postfix on my own server to send message from my site (password requests, account activation notices and other messages). I have phpMailer on the server and all the messages...
4
by: gurufordy | last post by:
Hello. Trying to use the ASP.net user functionality but it keeps failing on me. I have created a login and registration page for my site. When you fill in the registration form it should send a...
14
by: Warren Tang | last post by:
Hi I am using the mail function to send a mail like this: $b = mail("my_real_email_address@gmail.com", "Hello from PHP", "Hi, finally sent an email successfully"); But it failed. Could you...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.