630 |
{ |
{ |
631 |
message_t msg; |
message_t msg; |
632 |
attribute_t attr; |
attribute_t attr; |
|
int ret = 0; |
|
633 |
|
|
634 |
SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
635 |
msg = mu_scm_message_get (MESG); |
msg = mu_scm_message_get (MESG); |
730 |
} |
} |
731 |
#undef FUNC_NAME |
#undef FUNC_NAME |
732 |
|
|
733 |
SCM_DEFINE (mu_message_send, "mu-message-send", 1, 1, 0, |
SCM_DEFINE (mu_message_send, "mu-message-send", 1, 3, 0, |
734 |
(SCM MESG, SCM MAILER), |
(SCM MESG, SCM MAILER, SCM FROM, SCM TO), |
735 |
"Sends the message MESG. Optional MAILER overrides default\n" |
"Sends the message MESG. Optional MAILER overrides default\n" |
736 |
"mailer settings in mu-mailer.\n") |
"mailer settings in mu-mailer.\n" |
737 |
|
"Optional FROM and TO are sender and recever addresses\n") |
738 |
#define FUNC_NAME s_mu_message_send |
#define FUNC_NAME s_mu_message_send |
739 |
{ |
{ |
740 |
char *mailer_name; |
char *mailer_name; |
741 |
|
address_t from = NULL; |
742 |
|
address_t to = NULL; |
743 |
mailer_t mailer; |
mailer_t mailer; |
744 |
message_t msg; |
message_t msg; |
745 |
int status; |
int status; |
756 |
else |
else |
757 |
mailer_name = SCM_CHARS(_mu_scm_mailer); |
mailer_name = SCM_CHARS(_mu_scm_mailer); |
758 |
|
|
759 |
|
if (!SCM_UNBNDP (FROM)) |
760 |
|
{ |
761 |
|
SCM_ASSERT (SCM_NIMP (FROM) && SCM_STRINGP (FROM) |
762 |
|
&& address_create (&from, SCM_CHARS (FROM)) == 0, |
763 |
|
FROM, SCM_ARG3, FUNC_NAME); |
764 |
|
} |
765 |
|
|
766 |
|
if (!SCM_UNBNDP (TO)) |
767 |
|
{ |
768 |
|
SCM_ASSERT (SCM_NIMP (TO) && SCM_STRINGP (TO) |
769 |
|
&& address_create (&to, SCM_CHARS (TO)) == 0, |
770 |
|
TO, SCM_ARG4, FUNC_NAME); |
771 |
|
} |
772 |
|
|
773 |
if (mailer_create (&mailer, mailer_name)) |
if (mailer_create (&mailer, mailer_name)) |
774 |
{ |
{ |
775 |
return SCM_BOOL_F; |
return SCM_BOOL_F; |
785 |
status = mailer_open (mailer, MU_STREAM_RDWR); |
status = mailer_open (mailer, MU_STREAM_RDWR); |
786 |
if (status == 0) |
if (status == 0) |
787 |
{ |
{ |
788 |
status = mailer_send_message (mailer, msg); |
status = mailer_send_message (mailer, msg, from, to); |
789 |
mailer_close (mailer); |
mailer_close (mailer); |
790 |
} |
} |
791 |
mailer_destroy (&mailer); |
mailer_destroy (&mailer); |