The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sending mail from unix anki_1 UNIX for Dummies Questions & Answers 3 04-09-2008 04:03 PM
Sending mail thu unix hellotosatish UNIX for Dummies Questions & Answers 6 09-15-2007 09:46 PM
sending email via mail server parmeet UNIX for Advanced & Expert Users 1 02-09-2007 02:39 AM
Sending msg From Unix Server to an E-mail Address cgege HP-UX 2 12-04-2006 04:31 PM
block certain domain from sending mail to server legato UNIX for Dummies Questions & Answers 2 10-01-2006 09:43 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-02-2008
electroon electroon is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 12
Sending mail in C/C++ in unix server

Hi Frnds,

I have a task in my project wherein i have to send out a mail from my C++ code.With some file attachements.Please help me in this.

At a higher level wat i can tell is my code generated 3 csv file and i have to send these files as attachement.

My code is executed in unix server.So please suggest me how to do this.

If possible also please tell me how to do this in windows also.

Thanks in advance please reply asap.
  #2 (permalink)  
Old 01-02-2008
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by electroon View Post
My code is executed in unix server.
Use fork()/exec()/wait() or system() to run a shell script to wrap the email client.

Quote:
Originally Posted by electroon View Post
If possible also please tell me how to do this in windows also.
Use MAPI2.
  #3 (permalink)  
Old 01-02-2008
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
  
 

Join Date: Dec 2007
Posts: 427
popen() using sendmail directly might be an option to.
  #4 (permalink)  
Old 01-03-2008
electroon electroon is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 12
Can u elaborate

Can u please tell more details i am somewhat naive user
  #5 (permalink)  
Old 01-03-2008
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by electroon View Post
i am somewhat naive user
But you can program in C & C++?

On UNIX, I was suggesting you write a script to wrap the email functionality so this can be customized without recompilation, then call this from the C++ program.

On Windows you should use the MAPI 2 interface, this provides an COM/OLE interface to a mail provider and supports adding attachments as part of the API.
  #6 (permalink)  
Old 01-04-2008
ramen_noodle ramen_noodle is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2007
Location: Virginia, USA.
Posts: 251
I'm in agreement with the other folks in this thread that
using established systems mail tools to accomplish what you
are doing is simpler.

If you really need to do the entire project in C you could take
a look at libesmtp -- libESMTP - A Library for Posting Electronic Mail
Or possibly the c-client library bundled with UW imap: UW IMAP software--IMAP Information Center.
  #7 (permalink)  
Old 01-21-2008
softweyr softweyr is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 2
Post

Quote:
Originally Posted by electroon View Post
Can u please tell more details i am somewhat naive user
popen is a very simple function to use. It allows you to open a system command as a FILE stream, for reading or writing. To send an email, you will want to open a stream for writing so you can "print" the contents of the email into the function:

Quote:
FILE *mailer = popen("/usr/bin/mail -s 'Some subject here' user@domain", "w");
fprintf(mailer, "Hello %s,\nThis note is to inform you that your job completed successfully.\n", username);
pclose(mailer);
You would, of course, want to add some error checking to this.
Closed Thread

Bookmarks

Tags
sendmail

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0