Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending e-mail via a C program

Status
Not open for further replies.

sunlearner

Technical User
Mar 28, 2003
2
US
Hi,

Does anyone know how to compose a e-mail message in a C program on Sun/Solaris and submit the e-mail to an e-mail account (e.g., mail.yahoo.com with know username/password) for delivery? My system has internet connection but is not set up as a mial server. Is there a way to use TCP/IP to log into my e-mail account (e.g., mail.yahoo.com) and deliver the mail automatically?

Thanks!

 
The syntax for sending a mail manually is by telnetting to the mail port (25) - you shouldn't need to know the
account or password since you're sending. The server you connect to is the outgoing smtp server not the one you log into to receive mail (the POP3 server). The dialogue between the ## is what the server expects.

##
telnet smtp.yahoo.com 25
helo your.company.com
mail from: <you@your.company.com>
rcpt to: <you@yahoo.com>
rcpt to: <a.nother@somewhereelse.com>
data
From: you@your.company.com
To: you@yahoo.com, a.nother@somewhereelse.com
Date: Fri, 28 Mar 2003 12:34:50 GMT
Subject: Test Email
Reply-To: you@your.company.com

This is a test email

Regards Me

--
My companies' lengthy disclaimer
.
quit
##

The From:, To:, Date:, Subject:, Reply to: are the mail envelope and in a quick and dirty system can be omitted if all your'e interested in is getting the text out. The message starts with data and ends with a single dot on a line by itself.

This all depends on your firewall letting your server (rather than the companies mail server) out on port 25. And yahoo not having some fancy authentication of their own (I tried just now and yahoo wouldn't let me connect although my ISP does allow it). You can imagine allowing programs to send emails willy nilly is inviting for spammers!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top