/*******************************************************************************
        smtp.c
        Z-World, 2000

        A small program that uses the SMTP library
        to send an e-mail.
*******************************************************************************/

/***********************************
 * Configuration                   *
 * -------------                   *
 * All fields in this section must *
 * be altered to match your local  *
 * network settings.               *
 ***********************************/

/*
 *   These macros need to be changed to the appropriate values or
 *   the smtp_sendmail(...) call in main() needs to be changed to
 *   reference your values.
 */

#define FROM     "myaddress@mydomain.com"
#define TO       "myaddress@mydomain.com"
#define SUBJECT  "test mail"
#define BODY     "You've got mail!"

/*
 *   You must change the following values to whatever
 *   your local IP address and netmask are. Contact your
 *   network administrator for these numbers.
 */
 
#define MY_IP_ADDRESS "10.10.6.101"
#define MY_NETMASK    "255.255.255.0"
#define MY_GATEWAY    "10.10.6.19"
#define MY_NAMESERVER "10.10.6.1"

/*
 *   The SMTP_SERVER macro tells DCRTCP where your mail server is.  This
 *   mail server MUST be configured to relay mail for your controller.
 *
 *   This value can be the name or the IP address.
 */

#define SMTP_SERVER "mymailserver.mydomain.com"

/*
 *   The SMTP_DOMAIN should be the name of your controller.  i.e.
 *   "somecontroller.somewhere.com"  Many SMTP servers ignore this
 *   value, but some SMTP servers use this field.  If you have
 *   problems, turn on the SMTP_DEBUG macro and see were it is
 *   bombing out.  If it is in the HELO command consult the
 *   person in charge of the mail server for the appropriate value
 *   for SMTP_DOMAIN. If you do not define this macro it defaults
 *   to the value in MY_IP_ADDRESS.
 *
 */
 
//#define SMTP_DOMAIN "mycontroller.mydomain.com"

/*
 *   The SMTP_DEBUG macro logs the communications between the mail
 *   server and your controller.  Uncomment this define to begin
 *   logging
 */

//#define SMTP_DEBUG
 
/********************************
 * End of configuration section *
 ********************************/

#memmap xmem
#use dcrtcp.lib
#use smtp.lib

main()
{
	sock_init();

	smtp_sendmail(TO, FROM, SUBJECT, BODY);
		
	while(smtp_mailtick()==SMTP_PENDING)
		continue;

	if(smtp_status()==SMTP_SUCCESS)
		printf("Message sent\n");
	else
		printf("Error sending message\n");
}