Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Потрепаться";
Текущий архив: 2003.02.10;
Скачать: [xml.tar.bz2];

Вниз

Можно ли с помощью cgi отправлять письма?   Найти похожие ветки 

 
Шишкин Илья   (2003-01-24 17:46) [0]

Сабж


 
Delirium^.Tremens   (2003-01-24 18:10) [1]

Можно:

int post::new_message() {
static Layout l("Sending Mail") ;
l.print(1) ;
cgi.readfrom(config.preferences()) ;
String real_from(cgi["Name"].as_text()) ;
String if_unset_org(cgi["Organization"].as_text()) ;
if ( real_from == NULL_String )
real_from = cgi.remote_user() + "@" + config.domain() ;
else
real_from = real_from + " <" + cgi.remote_user()
+ "@" + config.domain() + ">" ;

cgi.define(3,
"Attach:longfile",
"AttachType:select",
"Body:textarea"
) ;
cgi.form() ;
message.read(cgi["my_ref"].as_text()) ;

// parse the headers supplied to us
// add from and org if not supplied
// check To and Subj
Map& headers = message.parse_headers(cgi["Head"].as_text()) ;

String hh("To") ;
String s(cgi[hh].as_text()) ; // strip down to bare addresses
if (s != NULL_String) {
int n(s.freq(",")+1) ;
if ( n > 1 ) {
Regex comma("[ \t]*,[ \t]*") ;
String* ss = new String[n] ;
split(s,ss,n,comma) ;
while (--n >= 0) {
s.at(ss[n]) = Address(ss[n]).email() ;
}
headers[hh] = s ;
delete [] ss ;
} else
headers[hh] = Address(s).email() ;
} else if (headers[hh] == NULL_String)
message.add_error("No recipient specified!\n") ;

hh = "Subject" ;
if (cgi[hh].as_text() != NULL_String)
headers[hh] = cgi[hh].as_text() ;
else if (headers[hh] == NULL_String)
message.add_error("No subject specified!\n") ;

hh = "From" ;
String hs = "Sender" ;
if (headers[hh] == NULL_String)
headers[hh] = real_from ;
else if (headers[hs] == NULL_String)
headers[hs] = real_from ;
else {
hh = "X-Authenticated-Sender" ;
headers[hh] = real_from ;
}

hh = "Organization" ;
if (headers[hh] == NULL_String)
headers[hh] = if_unset_org ;

hh = "Message-Id" ;
hs = "<" ;
hs += cgi["my_ref"].as_text() + "@" + cgi.server_name() + ">" ;
headers[hh] = hs ;

if (strlen (cgi["Attach"].as_longtext()) < 2)
message.body(cgi["Body"].as_text()) ;
else {
message.start_mime() ;
message.add_mime(cgi["Body"].as_text()) ;
message.add_mime(cgi["Attach"], cgi["AttachType"].as_text()) ;
message.end_mime() ;
}
return 0 ;
}



http://www.cgi-resources.com/



Страницы: 1 вся ветка

Форум: "Потрепаться";
Текущий архив: 2003.02.10;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.009 c
1-28786
SaperXL
2003-02-01 20:35
2003.02.10
TRichEdit верхняя строка в редакторе


1-28764
XPatriot[d.m.b]
2003-02-01 00:43
2003.02.10
Работы с тригонометрическими функциями


14-29012
BF7ru
2003-01-23 13:45
2003.02.10
Копирование CD-DA


9-28578
Delphi 5.01
2002-08-28 18:51
2003.02.10
Problema s zagruskoi bitmap-ov is


4-29177
BigDAN
2002-12-25 14:35
2003.02.10
Взведена ли критическая секция???





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский