1,105,423 Community Members

Mail

Member Avatar
Labdabeta
Master Poster
769 posts since Feb 2011
Reputation Points: 161 [?]
Q&As Helped to Solve: 42 [?]
Skill Endorsements: 6 [?]
 
0
 

How can I send an email through C++. I need to make the following:

bool SendMail(char* from, char* to, char* title, char* msg)
{
    //What now?
    //Return true on success, false otherwise
}
Member Avatar
VernonDozier
Posting Expert
5,632 posts since Jan 2008
Reputation Points: 2,218 [?]
Q&As Helped to Solve: 768 [?]
Skill Endorsements: 26 [?]
Featured
 
0
 

>> How can I send an email through C++.


You don't. Or at least you don't through standard C++. You need to either use something like libcurl and pass this information to some language like PHP which DOES have built-in mail functionality or you need to find some other C++ library that can mail things without using something like PHP as an intermediary. I've done the former many times. Never done the latter.

http://curl.haxx.se/libcurl/cplusplus/

But you're not going to find anything within Standard C++ that does what you are trying to do.

Member Avatar
Labdabeta
Master Poster
769 posts since Feb 2011
Reputation Points: 161 [?]
Q&As Helped to Solve: 42 [?]
Skill Endorsements: 6 [?]
 
0
 

I don't fully understand. Is there some way to find some kind of tutorial for libcURL?

Member Avatar
WaltP
Posting Sage w/ dash of thyme
9,363 posts since May 2006
Reputation Points: 2,905 [?]
Q&As Helped to Solve: 1,151 [?]
Skill Endorsements: 45 [?]
Team Colleague
 
1
 

Allow me :icon_rolleyes:

Maybe you can learn something from this post...

Member Avatar
Labdabeta
Master Poster
769 posts since Feb 2011
Reputation Points: 161 [?]
Q&As Helped to Solve: 42 [?]
Skill Endorsements: 6 [?]
 
0
 

That was an awesome link! You are right, google is our friend. Thanks a lot!

Member Avatar
VernonDozier
Posting Expert
5,632 posts since Jan 2008
Reputation Points: 2,218 [?]
Q&As Helped to Solve: 768 [?]
Skill Endorsements: 26 [?]
Featured
 
1
 

I could have sworn I gave you that exact same link. How come Walt gets rep and I don't? :icon_cry:

Yes, "Let me google that for you" is a cool site.

Member Avatar
Labdabeta
Master Poster
769 posts since Feb 2011
Reputation Points: 161 [?]
Q&As Helped to Solve: 42 [?]
Skill Endorsements: 6 [?]
 
0
 

I have a problem. I have tried absolutely everything from libcurl to telnet commands. For some unknown reason they all end up giving me some kind of warning or another saying that the message simply could not be sent. I was thinking maybe since I use an unusual Email provider I am unable to send emails or something. But I have the smtp so it shouldn't be too big a problem. Any ideas of why I cannot send my emails?

Member Avatar
VernonDozier
Posting Expert
5,632 posts since Jan 2008
Reputation Points: 2,218 [?]
Q&As Helped to Solve: 768 [?]
Skill Endorsements: 26 [?]
Featured
 
0
 

I have a problem. I have tried absolutely everything from libcurl to telnet commands. For some unknown reason they all end up giving me some kind of warning or another saying that the message simply could not be sent. I was thinking maybe since I use an unusual Email provider I am unable to send emails or something. But I have the smtp so it shouldn't be too big a problem. Any ideas of why I cannot send my emails?

Details, details. There are several possible problems/explanations/solutions. The explanation/solution will depend on the problem. We don't know what you've tried. As mentioned, I've only done it through some server-side script like PHP or Perl, so if you're doing it another way, I'm of no help. Several scenarios, assuming you're passing from a C++ executable on some personal computer using CURL to a properly configured server-side script like PHP which does the mail.

  1. Info never gets from the C++ program to the PHP script.
  2. PHP script doesn't mail it correctly.
  3. PHP script mails it fine, but the mail server on either end rejects it or whatever and the mail never gets it.
  4. PHP script mails it fine, the actual e-mail gets sent, but somehow, PHP doesn't return the correct message to the C++ program via libcurl.
  5. PHP sends it back fine, but it never gets back to the C++ program due to firewall, etc.
  6. C++ Libcurl/gets it back fine, but there's some bug in the C++ program.

1, and 6 I can help with provided it's not some firewall or port issue or something. 2 and 4 I can help with, but there's a PHP forum so it might be better to ask about PHP's mail function there. Ditto Perl or any other language.

Routers, firewalls, e-mail server configuration, etc., you have the wrong guy and definitely the wrong forum. If you're doing it any other way than posting from a C++ program to a server-side mailing script, I can be of no help. Make sure it's a problem with the C++/Curl end of it by doing a mail directly from the server(i.e. no C++ program). If so, report back with the precise error and the code.

Member Avatar
Labdabeta
Master Poster
769 posts since Feb 2011
Reputation Points: 161 [?]
Q&As Helped to Solve: 42 [?]
Skill Endorsements: 6 [?]
 
0
 

*FACEPALM*
Drat! Foisted by my own spam filter. -Sheldon Cooper
As it turns out all the random methods I tried worked. They just ended up in my spam filter. Thank you for the help anyways!

Question Answered as of 2 Years Ago by VernonDozier and WaltP
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: