Sending emails in C program for multiple machines on Linux/OSX


 
Thread Tools Search this Thread
Top Forums Programming Sending emails in C program for multiple machines on Linux/OSX
# 1  
Old 12-18-2009
Sending emails in C program for multiple machines on Linux/OSX

Hey guys, i am creating a tool that'll run a couple network test, generate a report then email the report. Now i a bit stuck with the email sending part... I tried at first a script which worked on some machines but then it'll work fine on some machine and act up on others... I can't really rely too much on MTA as they will be random machines and I have no ways to know what MTA is installed or even if they are configured.

Im not deep enough in C to program my own mail sending software that I could included in my program, I've checked a couple open source mail delivery agent out there but as i said i'm not deep enough in C yet to remaster only the "mail sending" sections of the codes

Any ideas or something that couple point me in the right direction??? I need something that will have very minimal dependencies on the machine's software because it'll be random customers that'll run the test... Telnet script seemed an easy option but its acting up alot.

Thanks in advance,

Jess
# 2  
Old 12-18-2009
Can we assume that mail is configured on the customer's machine?

Are they all Linux/Unix with mail configured? If so, they should be running sendmail or something that has the same name and will accept minimal commands. If that's true, you can pipe your mail to "sendmail recipient@somewhere"

If not, the problem is that you don't know what SMTP server to use. One way to get around that is to use a program like CleanCode Email (see CleanCode Email ) and tell it to AUTH to a server you can send through. You can do the same sort of thing in Perl using the Mail::Sendmail module.

Unfortunately, you can run into trouble there because outbound firewall rules may not let you talk to that server.

If you aren't in control of the platform, I think you have to rely on a combination of methods, having your program try sendmail, try the known server, try just using plain old "mail" or "mutt" and go on to the next if it fails. Once again, though, it's hard to know that it failed because a misconfigured system can happily accept mail and never deliver it. For that reason, I'd try to my known SMTP server first (because you CAN programmatically know if that fails).

Obviously if the mail is going to you, you don't need to auth - just connect and send.


Oh, and you mentioned a telnet script? Try wrapping telnet in "expect" for better results.

Last edited by TonyLawrence; 12-18-2009 at 07:48 AM.. Reason: Additional thought about Expect
# 3  
Old 12-19-2009
Thanks Tony, sadly no I can't afford assuming sendmail/mutt or anything is pre-configured already... Alot of these customers are using our web-interface based email client therefor most aren't technically inclined enough to configured it themselves. Thats why I thought the script was a good solution until it acts up. However thanks for the great info I will look into this and let you know.

Best regards,

Jess
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Debian

Problem sending out emails

Hi, Our email relay server is a debian server. The application team in our company regularly receives email alerts from one hpux server (which is routed through the email relay server). Today we had problems whereby our company's email recipients are not receiving email alerts from the hpux... (2 Replies)
Discussion started by: anaigini45
2 Replies

2. Debian

Logcheck sending emails everywhere

Hi, I just recently installed logcheck running it at defaults. I don't have a /home/logcheck, even though the logcheck.conf MAILTO variable says "logcheck". Now I have a .forward in my regular home /home/awayand which gets an hourly report from logcheck but I have no clue how to turn that off. I... (0 Replies)
Discussion started by: awayand
0 Replies

3. Shell Programming and Scripting

Sending files to multiple emails

Hi All, I want to send each file to each email id as below. Instead of writing saparate 10 mail commands can we do it in a simple step. file1.csv to raghu.s@hps.com file2.csv to kiran.m@hps.com file3.csv to kenni.d@hps.com file4.csv to rani.d@hps.com file5.csv to sandya.s@hps.com... (2 Replies)
Discussion started by: ROCK_PLSQL
2 Replies

4. Shell Programming and Scripting

Hide from adress while sending emails

I have a shell script that sends email alerts to all the teams if there's any issue identified . This is the command that I use to send email alerts to others cat out.out | mail -s "Alerts on $date" $EMAILID Above code sends emails to all the users by default it sends emails to... (2 Replies)
Discussion started by: lazydev
2 Replies

5. Shell Programming and Scripting

How to change passwords for User accounts on multiple UNIX/Linux machines remotely?

Hello Experts, Need some direction on creating shell script for following environment: We have about 20 people in the team working as Oracle DBA's (sysdba's and appdba's). Total Servers which is a mix of Unix and Linux are 200. We do not have Root user access on any of the servers and... (3 Replies)
Discussion started by: sha2402
3 Replies

6. Shell Programming and Scripting

Counting lines and sending emails

What I am doing is running ps and search for any connection that is over a specified number, I set it to "1" for testing I want to send an email when any of them are over 50 I want them all in one email Below is the code what I want is to display the output of ps and grepping for "httpd" to a... (3 Replies)
Discussion started by: slufoot80
3 Replies

7. Solaris

How to use text Fonts while sending emails from mailx?

Hi Team, I want to use "Courier New" fonts while sending emails using mailx command from solaris command prompt. Because my SQL output is not printing in correct format in the email. Please assist. Let me know for any details. Thanks, (1 Reply)
Discussion started by: Mukharam Khan
1 Replies

8. UNIX for Dummies Questions & Answers

Sending Outgoing Emails from Unix Server

the server i have here is a Ubuntu server. it has nagios on it. after setting up nagios and having it work as it should, i realized at the very end of all my work that obviously nagios will also need to send out email alerts to a set of email addresses that it has in its database. my problem... (1 Reply)
Discussion started by: SkySmart
1 Replies

9. UNIX for Dummies Questions & Answers

Sending Emails to a unix process

Hi , I need to have a unix process which is setup to read all incoming mail for some user and process the same. How tough it is to code the same.Is there any way that we can download some shell scripts for the same from some internet site Kindly help. (2 Replies)
Discussion started by: xsriniva
2 Replies
Login or Register to Ask a Question