![]() |
| Home |
|
|
Function xn_smtpThis function sends an email message to an SMTP server.
struct rcpt {
char name[80];
};
typedef struct _attach_file_info {
char * attach_file;
char * attach_type;
} attach_file_info;
typedef struct _smtp_info {
BYTE smtp_server_ip[4];
char reverse_path[200];
char user_name[100];
char password[100];
char from[100];
char subject[100];
struct rcpt rcpts[5];
int num_rcpts;
int num_cc;
char * mime_fields;
char * body;
char * body_file;
char * attach;
int attach_len;
attach_file_info * at;
int num_attach_files;
} smtp_info;
int xn_smtp(smtp_info * info);
ParametersinfoPointer to a structure containing information about the email. See below or details. return valueReturns 0 if successful, otherwise SOCKET_ERROR. If an error occurred, call xn_getlasterror and xn_geterror_string to return the error value. Section Error Codes further describes each error. Possible values for this function are:
This function sends an email message using the SMTP protocol. Any number of attachments can be sent. Any attachment not having MIME type "text/plain" will automatically be base64 encoded. The message and possible attachment(s) can either be supplied as string constants or as files. If the message body is supplied as a file or it has attachments, vf_init must be called before this function. The various fields of structure smtp_info have the following meaning:
The fields of structure attach_file_info have the following meaning:
If _smtp_info.mime_fields contains a Content-Type header, then all _smtp_info.mime_fields are applied to the email body; if not, they are applied to the email header only (note that if the email has attachments, a multipart email is send with separate headers for the email, the body, and each attachment). If a Content-Type header is specified, the charset and a Content-Transfer-Encoding header should also be specified. If the Content-Transfer-Encoding header specifies base64, xn_smtp() will encode the body for you. Example:
mail->mime_fields = "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"
"Content-Transfer-Encoding: 8bit\r\n";
Supported Content-Transfer-Encodings are 7bit, 8bit, base64, and quoted-printable, but only base64 will make xn_smtp() perform any transcoding. If no Content-Type is specified by the application, the following default is applied: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Example MailDemo shows how messages can be sent using this function.
|