Нужно отправить почту из программы на C. Как это можно сделать?
PS: google меня походу не любит. неможет ничего найти.
Отправка почты из программы на C
Модератор: Модераторы разделов
-
watashiwa_daredeska
- Бывший модератор
- Сообщения: 4038
- Статус: Искусственный интеллект (pre-alpha)
- ОС: Debian GNU/Linux
Re: Отправка почты из программы на C
Код: Выделить всё
#include <stdio.h>
int main() {
FILE* sender = NULL;
sender = popen("sendmail -f sender@example.com recipient@example.com", "w");
fputs("From: sender@example.com\r\n"
"To: recipient@example.com\r\n"
"Subject: test, please ignore\r\n"
"Content-Type: text/plain; charset=ascii\r\n"
"\r\n"
"Test, please ignore\r\n"
"-- \r\n"
"Your C program\r\n",
sender);
fclose(sender);
return 0;
}Только лучше сделать настройку. Многим sendmail не подходит, вместо него могут использоваться другие программы, вроде msmtp.
Мои розовые очки
-
destr
- Сообщения: 128
- ОС: Debian
Re: Отправка почты из программы на C
libsmtp
http://directory.fsf.org/project/libsmtp/
Libsmtp allows programs to send mail directly through SMTP (no sendmail needed) and attaching and encoding mail in MIME standards. It is designed to be simple, secure, and small. It can send mail to multiple recipients in one go, and supports sending to CC and BCC recipients too.
http://directory.fsf.org/project/libsmtp/