473,836 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3044
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*****@Yah oo.com";
mail.From = "Me@MyDomain.co m";
mail.Subject = "Hello World!";
mail.Body = messageToGo;
mail.Fields.Add ("http://schemas.microso ft.com/cdo/configuration/smtpauthenticat e",
"1"); //basic authentication
mail.Fields.Add ("http://schemas.microso ft.com/cdo/configuration/sendusername",
"MyFullUserName Here"); //set your username here
mail.Fields.Add ("http://schemas.microso ft.com/cdo/configuration/sendpassword",
"MyPasswordHere "); //set your password here

System.Web.Mail .SmtpMail.SmtpS erver = "Mail.YourDomai n.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******** **********@twis ter.socal.rr.co m...
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.co m, 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*********@On ceOver.com> wrote in message
news:eD******** ******@tk2msftn gp13.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*****@Yah oo.com";
mail.From = "Me@MyDomain.co m";
mail.Subject = "Hello World!";
mail.Body = messageToGo;
mail.Fields.Add ("http://schemas.microso ft.com/cdo/configuration/smtpauthenti
cate", "1"); //basic authentication
mail.Fields.Add ("http://schemas.microso ft.com/cdo/configuration/sendusername
", "MyFullUserName Here"); //set your username here
mail.Fields.Add ("http://schemas.microso ft.com/cdo/configuration/sendpassword
", "MyPasswordHere "); //set your password here

System.Web.Mail .SmtpMail.SmtpS erver = "Mail.YourDomai n.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******** **********@twis ter.socal.rr.co m...
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******** ***********@twi ster.socal.rr.c om...
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.co m, 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*********@On ceOver.com> wrote in message
news:eD******** ******@tk2msftn gp13.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*****@Yah oo.com";
mail.From = "Me@MyDomain.co m";
mail.Subject = "Hello World!";
mail.Body = messageToGo;

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

mail.Fields.Add ("http://schemas.microso ft.com/cdo/configuration/sendusername
",
"MyFullUserName Here"); //set your username here

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

System.Web.Mail .SmtpMail.SmtpS erver = "Mail.YourDomai n.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******** **********@twis ter.socal.rr.co m...
>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
3213
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 System.Net.Mail. Now all of them works great with any email account but hotmail. So here is the C# code: MailAddress from = new MailAddress("ZZZ@CCC.com", "XXX"); MailAddress to = new MailAddress("SSS@hotmail.com", "YYY");
8
7289
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 user here at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify,
5
4225
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 mailto://mymail@domail.com. But this only works if the user has configured Outlook or something. Many users use web-based mails here so if I do so, Outlook Express's a new account wizard will pop-up. Futhure more this reveals user e-mails. Some people...
1
2294
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, which are stored in sql. i should be using this user name and pwd and check if it is the same as the userid and the pwd in the sql 4 table..IF so then: display the download url which is in sql3 by querying the four tables.. These four tables are...
3
2882
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 an SMTP server like if I am myself an SMTP server that is forwarding a mail. What classes can be used on .NET FW 2? Thanks,
2
1864
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 this in my web.config mail settings and when I put the mouse over it, i get the following message:
7
2775
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 (currently about 1000 messages are sent daily) are sent by SMTP through postfix. I'm contemplating moving this particular site's email to Gmail. Is it possible to send mail through Gmail's servers with authentication and everything?
4
3825
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 confirmation email with a link to activate the account. Nothing hi-tech here. However, it fails to send the email and provides the following error message: Transaction failed. The server response was: sorry, the sender name and auth login doesn't...
14
8381
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 guide me to get it work? Regards
0
9658
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10533
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10579
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7775
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6975
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5644
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5813
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4443
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.