LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-09-2004, 06:38 PM   #1
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Rep: Reputation: 32
Sending e-mails via a C++ program


How do I send an e-mail comprised of a char *buffer from a C++ program in Linux?


Edit: I don't care if I have to use a external program (such as sendmail). In fact, I'd prefer not having a library do it (unless it is easier, and the library isn't some propritary thing).

Last edited by The_Nerd; 11-09-2004 at 06:39 PM.
 
Old 11-09-2004, 06:42 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
"mail user@address\nthis is a subject\nthis is the message body\n^d"

Where the ^d is EOF.
 
Old 11-09-2004, 07:38 PM   #3
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Original Poster
Rep: Reputation: 32
That requires sendmail to be active.
 
Old 11-09-2004, 09:06 PM   #4
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Well yeah, you said you didn't mind if you had to use sendmail

If you're planning on doing MX lookups and SMTP communication directly in your C++ program then that's an entirely different monster.
 
Old 11-10-2004, 04:02 PM   #5
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Original Poster
Rep: Reputation: 32
Alright. I am trying to use the library jwSMTP (http://jwsmtp.sourceforge.net). I am trying to use MX lookup instead of smtp, but it is not working, got any ideas?

Code:
mailer mail(true);
mail.addrecipient("myemail@linuxmail.org");
mail.setsender("myname@localhost");
mail.setsubject("subject of mail");
mail.setmessage("Plain text message body");
mail.setserver("ns5.zoneedit.com");

mail.send( );

printf("<br><br>%s",mail.response().c_str());
It prints this response: 451 Requested action aborted: No MX records ascertained

???
 
Old 11-10-2004, 04:09 PM   #6
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
You can't use MX lookup in place of SMTP. They're 2 completely different things. An MX lookup just tells you the name of the mail server for a given domain. SMTP is the protocol used to communicate with that mail server. You'll need to do both an MX lookup and then connect to the mail server that the lookup tells you, then use SMTP to communicate with that mail server and send the message.
 
Old 12-05-2004, 09:56 PM   #7
YatseaLee
LQ Newbie
 
Registered: Dec 2004
Posts: 2

Rep: Reputation: 0
I want to find some c++ libs to send emails:

besides jwSMTP,what others are available?

would you please give some suggestion.

since I have google it, not find some good libs.

Last edited by YatseaLee; 12-05-2004 at 09:57 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending mails using port 25 rabeea Linux - Security 10 08-16-2004 11:53 PM
qmail not sending mails spank Linux - Software 0 05-21-2004 12:08 PM
Trouble sending mails with php Wagner Linux - Networking 3 12-15-2003 10:41 PM
Sending mails with eXtremail Ivanhoe Linux - Networking 2 12-31-2002 09:34 AM
sendmail sending fake e-mails klaus geld Linux - Security 4 07-18-2001 08:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration