![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum 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 |
| Sendmail 8.11 | jgt | UNIX and Linux Applications | 1 | 04-13-2008 12:34 PM |
| sendmail.cf | robsonde | UNIX for Dummies Questions & Answers | 0 | 01-28-2008 12:21 PM |
| rsh commands not getting executed from Solaris 10 System to AIX System | jumadhiya | SUN Solaris | 25 | 01-22-2007 02:26 AM |
| Taking a system off a network on a system | Terrible | Shell Programming and Scripting | 4 | 12-25-2006 06:49 AM |
| what is sendmail ? how to use it ? | vkandati | UNIX for Dummies Questions & Answers | 4 | 03-15-2005 08:43 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
using sendmail in system(cmd)
In 'C' I am trying to use the sendmail to send a message that program completed successful or failed.
The syntax is: sprintf(cmd,"/usr/sbin/sendmail roncayenne@ssss.org to: roncayenne@ssss.org from:root subject: PROGRAM SUCCESSFUL ."); system(cmd); But this is not working. Seems it does not like anything after the sendmail address and does not recognize the period at the end. Anyone know what is wrong with the above. Thanks! Ron |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
sendmail will work but we use a simpler way -- mailx:
Code:
EmailId = string which is email address
textfile can be empty or have message text in it - the file must exist
and be referenced by a pathname -- strcpy(textfile,"/path/to/textfile");
sprintf (cmd, "/usr/bin/mailx -s '%s' %s < %s", "Status Report", EmailId,textfile);
system (cmd);
|
|
#3
|
|||
|
|||
|
I sure wish we had mailx on our box but we don't so I am trying to get the sendmail to work. Any ideas on the syntax that would be similar to what you showed on mailx?
Thanks for the info and the reply... |
|
#4
|
|||
|
|||
|
This was tested and works on HPUX:
Code:
#include <stdlib.h>
int main()
{
char message[24]={0x0};
char cmd[128]={0x0};
const char *EmailId="jmcnama@piffl.com";
strcpy(message,"all is well");
sprintf(cmd, "echo \"%s.\" | sendmail %s ",message,EmailId);
system(cmd);
return 0;
}
|
|||
| Google The UNIX and Linux Forums |