void main() { sock_init(); // Wait for the interface to come up while (ifpending(IF_DEFAULT) == IF_COMING_UP) { tcp_tick(NULL); } #if _USER smtp_setserver(SMTP_SERVER); #endif #ifdef USE_SMTP_AUTH smtp_setauth ("myusername", "mypassword"); #endif 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"); }
int main() { int line_num; // This is our data handler opaque parameter. sock_init(); // Wait for the interface to come up while (ifpending(IF_DEFAULT) == IF_COMING_UP) { tcp_tick(NULL); } #if _USER smtp_setserver(SMTP_SERVER); #endif #ifdef USE_SMTP_AUTH smtp_setauth ("myusername", "mypassword"); #endif smtp_sendmail(TO, FROM, SUBJECT, NULL); // No fixed message smtp_data_handler(mail_generator, &line_num, 0); // Set message generator function line_num = 1; // Initialize for data handler benefit. while(smtp_mailtick()==SMTP_PENDING) continue; if(smtp_status()==SMTP_SUCCESS) printf("Message sent\n"); else printf("Error sending message\n"); return 0; }
/** * Initializes the SMTP Settings */ void setupSMTP() { // Set Auth smtp_setauth("alarm+yalost.me", "Al@rm"); // Copy the bodies strcpy(emailBody[0], BODY0); strcpy(emailBody[1], BODY1); strcpy(emailBody[2], BODY2); strcpy(emailBody[3], BODY3); }
void main() { static int counter; int channel; int i; // Initialize the controller brdInit(); // set up digital inputs 0-3 for (channel = 0; channel < 4; channel++) { setDigIn (channel); } sock_init_or_exit(1); #ifdef USE_SMTP_AUTH // Set the username and password to use for SMTP Authentication, an access // control mechanism used by some SMTP servers to allow legitimate users to // relay mail. (See <http://en.wikipedia.org/wiki/SMTP-AUTH> for a full // description). smtp_setauth (SMTP_AUTH_USER, SMTP_AUTH_PASS); #endif // initialize the email structure array with user defined emails init_emails(); printf ("Press buttons SW1 through SW4 on the demo board to send email from\n"); printf ("%s to %s.\n\n", SMTP_FROM, SMTP_TO); counter = 0; while(1) { costate { // check if user has activated a switch to send an email for (i = 0; i < 4; i++) { wfd { CheckSwitch[i](i); } } } printf("\rCode execution counter = %d", counter++); } }