![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to send email from HP Unix box | eurouno | UNIX for Dummies Questions & Answers | 3 | 12-03-2007 03:56 PM |
| How to Send email in UNIX | cooolthud | Shell Programming and Scripting | 1 | 01-23-2007 04:49 AM |
| Send email where # is in the email address - Using Unix | jingi1234 | UNIX for Dummies Questions & Answers | 1 | 05-23-2005 08:23 AM |
| Send email from unix terminal on Mac OS 10.x | hypamw | UNIX for Dummies Questions & Answers | 0 | 05-03-2005 08:26 PM |
| Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win) | Vetrivela | UNIX for Advanced & Expert Users | 2 | 02-15-2005 06:43 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
sample using mailx:
Code:
#include <stdlib.h>
#include <string.h>
#define cknull(x) if((x)==NULL) {perror(""); exit(EXIT_FAILURE);}
#define cknltz(x) if((x)<0) {perror(""); exit(EXIT_FAILURE);}
#define LIST_LEN 4
/*******************************
* email_it() -
* emails the contents of a file
* parms
* char *filename - file to email
* email recipients are in the array email_list[][]
* which has to be terminated with a zero-length element
********************************/
void email_it(char *filename)
{
char tmp[256]={0x0};
char fpBuffer[512]={0x0};
char email_list[LIST_LEN][256]={ {"username@somecompany.com"},
{"username@somecompany.com"},
{"username@anothercompany.com"},
{0x0}};
int i=0;
for(i=0;*email_list[i]>0x0;i++)
{
cknull(strcpy(tmp, email_list[i]));
cknltz(sprintf (fpBuffer,
"/usr/bin/mailx -s '%s %s' %s < %s",
"Please Review:",
filename,
tmp,
filename));
if(system (fpBuffer)==(-1))
{
perror("email failure");
exit(EXIT_FAILURE);
}
}
}
|