Chris OShea
Administrator
London
Posts: 613
Artist / designer / inventor
|
hi
do you know if there is a way of sending emails via smtp with file attachments included? does ofxMailUtils do this?
thanks chris
|
|
|
|
|
Logged
|
|
|
|
|
|
theo
Administrator
Amsterdam
Posts: 1007
|
btw did you ever try Poco's built in mail sending? Its meant to be able to SMTP.
Either way a simple wrapper for either would be super awesome - great for long term installations.
|
|
|
|
|
Logged
|
|
|
|
arturo
Administrator
barcelona
Posts: 2214
|
btw did you ever try Poco's built in mail sending? ofxMailUtil does just that : ) http://github.com/arturoc/ofxMailUtilsdoesn't support attachments unless you encode them manually in the content but it should be easy to add that feature.
|
|
|
|
|
Logged
|
|
|
|
theo
Administrator
Amsterdam
Posts: 1007
|
oh super nice, how did I miss that - yes attachments would be a great addition!
|
|
|
|
|
Logged
|
|
|
|
plong0
Vancouver, BC, Canada
Posts: 292
|
hmm... any updates on supporting email attachments?
We're getting ready to roll up our sleeves on building apps that send emails with attachments...
|
|
|
|
|
Logged
|
|
|
|
arturo
Administrator
barcelona
Posts: 2214
|
don't have very much time to modify it, but it should be easy... in ofxMailUtils the content is set in the poco mail message by calling setContent. that makes the message a 1 part only. it seems that by using addContent / addAttachment you can create a multipart message. usually files sent as attachments are encoded as base64, can't guess from the documentation if the function automatically does that or you need to encode the files before the docs for the mailmessage are in: http://www.appinf.com/docs/poco/Poco.Ne ... ssage.htmlwhen calling addAttachment you need to create a sourcepart, you can create a filepart: http://www.appinf.com/docs/poco/Poco.Ne ... ource.htmlor from a string http://www.appinf.com/docs/poco/Poco.Ne ... ource.htmlif it needs encoding, i think the way to go is to create a std filestream and use writeEncoded in mailmessage to encode that to an ostream, convert that to a string and then use stringpartsource to create the attachment from the encoded string
|
|
|
|
|
Logged
|
|
|
|
plong0
Vancouver, BC, Canada
Posts: 292
|
I was also wondering if there is any support for SSL or TLS?
I was hoping to talk to gmail with it, but they require SSL for POP3 and SSL or TLS for SMTP.
|
|
|
|
|
Logged
|
|
|
|
plong0
Vancouver, BC, Canada
Posts: 292
|
Those look like some great resources arturo, thanks!
I will hopefully getting into this sometime this week!
Cheers, -Pat
|
|
|
|
|
Logged
|
|
|
|
plong0
Vancouver, BC, Canada
Posts: 292
|
ok... got attachments working with the ofxMailUtils... it was actually really easy. I added to struct ofxMailMessage, a vector<string> attachments;and in the ofxMailMessage::getPocoMessage method, added: for(unsigned int i=0; i < attachments.size(); i++){ message.addAttachment(attachments[i], new Poco::Net::FilePartSource(ofToDataPath(attachments[i], true))); }
I'm still wondering about the SSL/TSL support though. If I could figure out how to recompile the poco library to include the SSL module, I could try tackling that as well.
|
|
|
|
« Last Edit: March 04, 2010, 12:00:30 AM by plong0 »
|
Logged
|
|
|
|
plong0
Vancouver, BC, Canada
Posts: 292
|
ok.. found a small bug that my message content wasn't getting sent when I had an attachment. And when there wasn't an attachment and I didn't set my message contentType to text/html, the message content was being received as an attachment instead of as the actual message body (in gmail at least).
The solution is simple enough:
in the ofxMailMessage::getPocoMessage() method...
change message.setContent(content);
to message.addContent(new Poco::Net::StringPartSource(content));
and everything works beautifully!
|
|
|
|
|
Logged
|
|
|
|
arturo
Administrator
barcelona
Posts: 2214
|
hey thanks for that!
just uploaded that changes to github, only i named the variable attachmentPaths in case there's a way of adding contents from memory.
about the SSL thing, sorry for late reply, i remembered it wasn't the standard way of compiling static but couldn't remember how. anyway has just been taking a look you need to:
./configure
then edit build/config/Darwin
replace the line
LINKMODE = SHARED with the line
LINKMODE = STATIC
and then:
make -s
|
|
|
|
|
Logged
|
|
|
|
plong0
Vancouver, BC, Canada
Posts: 292
|
oh, rad. thanks Arturo! I will look into compiling and implementing that tomorrow. Maybe soon we will be able to check gmail from within openFrameworks! hehe can't wait to make some weird email viz. :P
|
|
|
|
|
Logged
|
|
|
|
|