मुझे दृढ़ता से संदेह है कि सबसे अधिक उत्तर दिया गया जवाब "यह नौकरी के लिए गलत उपकरण है"। मैं स्वीकार करता हूं कि आर ईमेल भेजने और प्राप्त करने के लिए विशेष रूप से उपयुक्त नहीं हो सकता है, लेकिन यह स्क्रिप्टिंग भाषा है जिसे मैं सबसे अच्छी तरह जानता हूं। मैं आर में छोटे ईमेल भेजने और प्राप्त करने का एक तरीका ढूंढने की उम्मीद कर रहा हूं। क्या किसी को विंडोज प्लेटफ़ॉर्म पर ऐसा करने का एक स्थापित तरीका पता है? मैं BLAT और GetMail के संयोजन का उपयोग करने में सक्षम हो सकता हूं लेकिन मूल आर समाधान को प्राथमिकता दी जाएगी।आर का उपयोग करके मैं कैसे भेज/प्राप्त कर सकता हूं (एसएमटीपी/पीओपी 3) ईमेल?
संपादित करें: एक स्वीकार्य समाधान एसएसएल की आवश्यकता वाले सर्वरों के साथ इंटरफेस करने में सक्षम होना चाहिए।
संपादित करें 2: मैं 80% उत्तर पर अपना स्टैब प्रदान करता हूं। अफसोस की बात है कि एक आर मूल तरीका प्रदर्शित नहीं किया गया है। इसके बजाय मैं सिस्टम कॉल और कमांड लाइन प्रोग्राम के अपवित्र संयोजन का उपयोग करता हूं जो प्लेटफॉर्म पर संगत नहीं होने की संभावना है। आर देशी कॉलों को पीओपी 3 सर्वरों से जुड़े क्लाइंट्स और एसएसएल की समझ के तरीके से खोदने की आवश्यकता होगी जो मेरे पास वर्तमान में नहीं है। अन्य उत्तरों को अभी भी प्रोत्साहित किया जाता है।
##Note: Other programs are wrapped in R functions and system calls.
#They each have their own licenses which may or may not allow the use suggested here
#Programs used here:
#STunnel: http://www.stunnel.org/; Provides an SSL tunnel but requires OpenSSL
#OpenSSL: http://www.openssl.org/; OpenSSL to actually provide SSL
# Note that these .dlls should be placed with the stunnel exe.
# Also note that libssl32.dll may need to be renamed from ssleay32.dll
#Microsoft Visual C++ 2008 Redistributable (may be required for the SSL .dlls to work correctly)
#Blat: http://www.blat.net; a public domain SMTP sending program
#Getmail is free for non-commercial use. If you use it in a business environment, then a fee of $50 USD is payable to Tim Charron.
#Stunnel is a TSR, so it will need to be killed from the task manager if there is an issue. If you are willing to install it as a service you may be able to tweak my code to start and stop the service.
#My current code does not create .conf file for stunnel the way a full version ought. Check http://spampal.sanesecurity.com/manual_eng/servers/stunnel/stunnel.htm#sconfig21 to create the appropriate configuration file.
#Set the config values as appropriate
##Config##
BLAT.loc <- "c:/Programming/R/Rmail/blat262/full/blat.exe"
GetMail.loc <- "C:/Programming/R/RMail/getmail133/getmail.exe"
stunnel.loc <- "C:/Programming/R/RMail/stunnel/stunnel-4.11.exe"
#The set mail function assigns the username and password to be used as well as the smtp and pop3 servers it starts stunnel (and assumes that the stunnel.conf file is present and set correctly).
setMail <- function(user,pw,SSL=FALSE,smtp="127.0.0.1:259",pop3="127.0.0.1:1109")
{
if (SSL==TRUE)
{
print("Starting stunnel; you will need to kill this from the task-manager")
system(stunnel.loc,wait=FALSE)
Sys.sleep(2) #Give it time to start
}
return(list(user=user,pw=pw,smtp=smtp,pop3=pop3,SSL=SSL))
}
#function to send mail, myMail is the resulting list from setMail
sendmail <- function(myMail, to, subject, msg,VERBOSE=FALSE)
{
writeLines(msg, "out.txt", sep = "\n", useBytes = FALSE)
targ <- paste(getwd(),"/out.txt",sep="")
call <- paste(BLAT.loc, ' "',targ,'" -subject "',subject,'" -to ',to," -u ",myMail$user," -pw ",myMail$pw, " -f ",myMail$user, " -debug -server ",myMail$smtp,sep="")
res <- system(call,intern=TRUE)
if (VERBOSE) {return(res)}
}
#function to get mail, myMail is the resulting list from setMail; it returns a list with one element that contains everything unparsed, another list provides the number of messages remaining on the server.
getmail <- function(myMail,VERBOSE=FALSE)
{
unlink("MSG1.txt") #drop previous get
#download next message
call <- paste(GetMail.loc," -u ",myMail$user," -pw ",myMail$pw," -s ",strsplit(myMail$pop3,":")[[1]][1],
" -port ",strsplit(myMail$pop3,":")[[1]][2]," -n 1",sep="")
res <- system(call,intern=TRUE)
if (VERBOSE) {print(res)}
nmsgtxt <- res[grep("messages on the server.",res)]
nstart <- regexpr("There are",nmsgtxt)
nend <- regexpr("messages on the server.",nmsgtxt)
nmess <- as.numeric(substr(nmsgtxt,10,nend-1))-1
x <- readLines("MSG1.txt",-1)
return(list(message=x,remaining=nmess))
}
प्रयोग मामले: सीधे शब्दों में कहें, मैं आर संदेश जिनकी सामग्री SMTP सर्वर को आर लिपि में कहीं और निर्धारित किया जाता है भेजने में सक्षम होना की आवश्यकता है। प्रतिभागियों को ईमेल प्राप्त होगा और इसका जवाब मिलेगा। मुझे अपने पीओपी 3 सर्वर से अपनी प्रतिक्रिया पुनर्प्राप्त करने और इसे आर डेटा संरचना में स्टोर करने की आवश्यकता है ताकि मैं उस पर पोस्ट प्रोसेसिंग कर सकूं। प्रैक्टिस में, मैं आर के माध्यम से अनुभव नमूना करने का एक तरीका स्थापित कर रहा हूं। यही है, आर एक प्रतिभागी को ईमेल कर सकता है "आज आप कैसे हैं (1 = खराब; 7 = ग्रेट)?" प्रतिभागी "4" का जवाब दे सकता है, और मैं सांख्यिकीय विश्लेषण के लिए डेटाबेस में पूछे गए प्रश्न, प्रतिक्रिया, और इसी तरह से मेल खाता हूं।
इसी प्रकार के (लेकिन एक नकली कारण एसएसएल का) http://stackoverflow.com/questions/2885660/how-to-send-email-with-attachment-from-r-in- विन्डोज़ और http://stackoverflow.com/questions/3572607/sendmailr-part2 -sending-files-as-mail-attachments – Marek
संपादन 2 और संपादन 3 के स्वर के साथ क्या हो रहा है? क्या वास्तव में इसके लिए बुलाया जाता है? –
एक साइडेनोट पर, पर्ल (और एक्सटेंशन पायथन द्वारा) अभी भी एक मुख्य स्क्रिप्टिंग भाषा है जो कई वेबसाइटों के लिए बैकएंड के रूप में उपयोग की जाती है। इसमें ई-मेल भेजने और प्राप्त करने के लिए (स्वचालित) के लिए कार्यों का एक धन शामिल है (कई मेलिंग सूचियां पर्ल में इन कार्यक्षमताओं का लाभ लेती हैं)। मैं आवश्यकता के साथ एक प्रोग्रामर भी हूं, लेकिन मुझे खुशी है कि मैंने एक से अधिक "टूल" (यानी भाषा) के साथ काम करना सीखा। लंबे समय तक, यह जाने का एक बेहतर तरीका लगता है। इसके अलावा, पर्ल और आर को जोड़ा जा सकता है। या पायथन बंद कोर्स, यह भी कर सकते हैं। –