Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 SMTP
Index -> Programming, C++ -> C++ Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Justin_




PostPosted: Mon Jan 30, 2006 1:22 pm   Post subject: SMTP

Hi, as I mentioned I'm working on sending out emails, but I'm confused about a number of things.

First, why is an smtp server necessary? I mean, all I want to do is send an email from my computer, to some smtp server, is it necessary to have some mediator in between there? (I ask this question because in some of the code i've looked at your expected to state a smtp server, most ppl put "localhost" but this isn't expected to work unless you've set yourself up as an smtp server, or so I gather)

Second, I understand that it is possible to send an email from your computer without setting it up as an smtp server, how?

Third, I don't understand how its possible that I send an email and it gets picked up. To explain what I mean, in the code I've looked at I don't see exactly who the connection is made with. Is there some universal SMTP server that accepts your mail and routes it to the appropriate domain? Like a DNS?

And lastly, does anyone have a reliable library I can work with, for either C# or C++ to send an email. And if so, can you explain how I do all the linking in order to use the library. That's one thing that has thus far evaded me.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Mon Jan 30, 2006 3:07 pm   Post subject: (No subject)

Don't use these languages. They'll make it an absolute pain in the... ummm... neck.

Use something rather more high level.
Justin_




PostPosted: Mon Jan 30, 2006 6:00 pm   Post subject: (No subject)

C# isn't high enough for you? Its very easy to email with c++, all you need is premade classes. . .
rizzix




PostPosted: Mon Jan 30, 2006 7:23 pm   Post subject: Re: SMTP

Justin_ wrote:
First, why is an smtp server necessary?
It is, cuz that's just the way things are designed.

Justin_ wrote:
Second, I understand that it is possible to send an email from your computer without setting it up as an smtp server, how?
Use somone else's smtp server, usually your ISP's -- cuz it's usually free (actually you pay for it).

Justin_ wrote:
Third, I don't understand how its possible that I send an email and it gets picked up. To explain what I mean, in the code I've looked at I don't see exactly who the connection is made with. Is there some universal SMTP server that accepts your mail and routes it to the appropriate domain? Like a DNS?
I believe you are unnecessarily trying to re-implement the wheel? You say you are using C#? In that case I suggest you use Java and check out: Jakarta Commons' Email

Justin_ wrote:
And lastly, does anyone have a reliable library I can work with, for either C# or C++ to send an email. And if so, can you explain how I do all the linking in order to use the library. That's one thing that has thus far evaded me.
Well, I'm not much of a .NET guy, so yea I really don't know, but as I said, if you move to Java... you'll find more than enough libraries for your needs.
wtd




PostPosted: Mon Jan 30, 2006 10:55 pm   Post subject: (No subject)

Justin_ wrote:
C# isn't high enough for you? Its very easy to email with c++, all you need is premade classes. . .


No, C# is not. If you think it is, then you need more exposure to really high-level languages and libraries.

With C++, yes, all you need is premade classes... and you have to worry about compiling and linking and other crap that has nothing to do with sending e-mail.
Justin_




PostPosted: Mon Jan 30, 2006 11:26 pm   Post subject: (No subject)

okay, how can i go about finding my ISP's smtp server? just a google?

And to wtd, i don't understnad how you figure writing 6 lines of code is too complicated. Once you include the libraries its literally less tahn 6 lines of code to send the email out... And i'd really like to learn how to link to libraries and all that other jazz, which is why i'm bothering to do this in the first place. I'm major noob at linking and using compile arguments and stuff.
Justin_




PostPosted: Mon Jan 30, 2006 11:58 pm   Post subject: (No subject)

c++:

static void Main(string[] args)
                {
                        Email mail = new Email();
                        mail.To.Add(EmailAddress.Parse("hi@hotmail.com"));
                        mail.From = EmailAddress.Parse("commander@opteum.com");
                        mail.Subject="foo";
                        mail.Body = "blah blah blah";
                        //mail.Attachments.Add(EmailAttachment.FromFile(@"C:\Foo.txt"));
                        //SmtpService.SmtpServer = "exch-atl01";
                        SmtpService.SendDirectEmail(mail);
                }


This code is all that is necessary to send an email. However.. I can't figure out the smtpServer part.. Like what do I use ?!?

I dont know how much higher you would go wtd, but this is certainly within my realm of possiblity, plus I think its best that I learn how to link and compile properly.

So please lets stay on the topic of SMTP in C++/C#
Justin_




PostPosted: Tue Jan 31, 2006 1:58 pm   Post subject: (No subject)

This is an authentication question, or else: another smtp question.

Using "smtp.broadband.rogers.com" as the smtp (i googled it) it will not send because the email is not properly authenticated. (it mentioned this at the same place i got it from)

Can you lend me any hints on how to authenticate the email, so I can use roger's smtp? Or else, tell me a different way I can send emails Very Happy
c++:

        private void button1_Click(object sender, EventArgs e)
        {
            //create the mail message
            MailMessage mail = new MailMessage();

            //set the addresses
            mail.From = new MailAddress("me@mycompany.com");
            mail.To.Add("sendingToYou@hotmail.com");

            //set the content
            mail.Subject = "This is an email";
            mail.Body = "this is a sample body";

            //send the message
            SmtpClient smtp = new SmtpClient("smtp.broadband.rogers.com");
            smtp.Send(mail);
        }
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Tue Jan 31, 2006 2:24 pm   Post subject: (No subject)

Use Google and MSDN if you're using C#.

http://www.google.ca/search?hs=MR0&hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=.net+send+smtp+message+with+authentication&btnG=Search&meta=

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebmailsmtpmailclasstopic.asp

Unfortunately it appears that there is no way out of the box to do what you want, unless you drop down to basic socket programming. Lots of fun that is.
wtd




PostPosted: Tue Jan 31, 2006 2:32 pm   Post subject: (No subject)

code:
require 'net/smtp'

Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
                'Your Account', 'Your Password', :login) do |smtp|
   smtp.open_message_stream('from@example.com', ['dest@example.com']) do |f|
      f.puts 'From: from@example.com'
      f.puts 'To: dest@example.com'
      f.puts 'Subject: test message'
      f.puts
      f.puts 'This is a test message.'
   end         
end


Wink
rizzix




PostPosted: Tue Jan 31, 2006 3:01 pm   Post subject: (No subject)

Justin_ wrote:
Using "smtp.broadband.rogers.com" as the smtp (i googled it) it will not send because the email is not properly authenticated. (it mentioned this at the same place i got it from)
You should not be googling such info, cuz it's usually specific from location to location.

Look up your rogers setup manual or something.. They usually have it filled in there.

Or, you might want to call them up. Just inquire about your smtp server. They should give you the details
Justin_




PostPosted: Tue Jan 31, 2006 7:55 pm   Post subject: (No subject)

wtd, i know how to google, obviously if I am asking in this forum its because I want highly selective information and I want it said by someone who knows what they are talking about and I can't find my specific answers easily with google...

What langauge is the code you posted and why did you post it?

Rizzix, yes thanks, I am checking it out with rogers, still haven't been able to send an email though. I'm working direct sending by setting up an smtp on my computer to see how that works out.
wtd




PostPosted: Tue Jan 31, 2006 8:01 pm   Post subject: (No subject)

It's Ruby. I posted to show that there are places where you can do this out of the box.. and easily at that.

I suggested Google and MSDN because there are numerous discussions available on how to achieve what you're trying to do. As I mentioned, there don't appear to be any out of the box solutions for .Net applications. Solutions would appear to involve using third party libraries (whose quality is generally suspicious) or manually manipulating sockets yourself.
Justin_




PostPosted: Tue Jan 31, 2006 8:46 pm   Post subject: (No subject)

In .NET there is a very straightforward way to do it. The system.net.mail namespace is in the system.dll and has been improved from the system.web.mail (whose quality was suspicious).

Just a little F.Y.I.

Thanks for help.
wtd




PostPosted: Tue Jan 31, 2006 9:03 pm   Post subject: (No subject)

Yay for redundant libraries and docs that only point to the library of lower quality!
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: