I'm using MimeKit for creating s/mime encrypted mails with attachments.
As soon as an attachment name has special chars, e.g. äüö, the attachemnt name gets lost and is displayed like "unnamend attachment 123.dat" in Outlook.
Unencrypted mails do fine, so the only difference is just msg.Encrypt(context).
Are there some constraints in MimeKit regarding this use case or do I have to do more to get this working?
Iterate over the ContentType and ContentDisposition parameters of the attachment (before encrypting) and set the EncodingMethod of each parameter to ParameterEncodingMethod.Rfc2047.
The problem is probably that Outlook can't handle rfc2231-style encoding of parameter values.
example:
foreach (var param in attachment.ContentType.Parameters)
param.EncodingMethod = ParameterEncodingMethod.Rfc2047;
foreach (var param in attachment.ContentDisposition.Parameters)
param.EncodingMethod = ParameterEncodingMethod.Rfc2047;
Related
i have a simple email sender using coldfusion 10 that first allows users to upload and then attach those files to the email.
those files are attached like;
<CFMAILPARAM FILE="#file#" DISPOSITION="attachment" TYPE="#type#/#subtype#">
today we uploaded and sent out two attachments with filenames like;
Blah_Blah_something_off_Brazil_Site-Table_4.docx
Blah_something_off_Brazil_Sites-map.pdf
but in outlook/live mail the attachments were being shown as;
ATT00247.docx
ATT00249.pdf
i've had trouble before with outlook/live mail and attachments being given different filenames, but that was down to spaces in the filename. these files have no spaces. so i had a look at the email source, which was showing the attachments as;
Blah_Blah_something_off_Bra%7ail_Site-Table_4.docx
Blah_something_off_Bra%7ail_Sites-map.pdf
its replaced the z's with the %7a
i had a look at the email source in thunderbird, which was displaying the names correctly, but even there, in the source, the filenames had the z's replaced with %7a
so i created a text file, saved it as brazil.txt, uploaded and sent it out
in the email source in outlook and thunderbird, it came through as;
bra%7ail.txt
i know that a %7a is a url encoded z. the uploaded/saved on server file doesn't have that - it has the z. its only when emailed as an attachment that the z's get changed to %7a
anyone have any idea whats going on?! why doesn't coldfusion cfmail like the letter z?!
edit - so i just created a text file called
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.txt
and it came through as;
abcdefghijklmnopqrstuvwxy%7aABCDEFGHIJKLMNOPQRSTUVWXYZ.txt
so its only lowercase z's that get changed ...
addition
well, i fixed it - removing the TYPE="#type#/#subtype#" did the job, but i don't why that was causing trouble. below is what is was filling in for the type/subtype ( which came from the upload/cffile ) for each of the files;
zanzibar1.txt - text/plain
Blah_Something_off_Brazil_Sites-map-test1.pdf - application/pdf
Blah_Blah_Something_off_Brazil_Site-Table_4-test1.docx - application/vnd.openxmlformats-officedocument.wordprocessingml.document
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1.txt - text/plain
all the email clients i've tested don't seem to care about the type/subtype missing and they all display the correct filename. but i don't see whats wrong with type/subtype ...
I'm using EmailMultiAlternatives to serve a lot of our emails to customers. We'd ideally like to change the 'to' field so that it reflects their name rather than the email address itself, as apparently that makes spam filters less likely to block your email.
I know how to change the from field from this:
msg = EmailMultiAlternatives("subject", text_content, "from#bla", ["to#bla"])
to this:
msg = EmailMultiAlternatives("subject", text_content, "from, bla <from#bla>", ["to#bla"])
but this doesn't seem to work for the 'to' field.
Any suggestions for how I could fix the 'to' field too?
Thanks!
This will work for a to field:
msg = EmailMultiAlternatives("subject", text_content,
"from#example.com",
["Some Name <to#example.com>"])
What will fail is the presence of a comma (,) anywhere in the recipient string, because Django will split the recipient into two at that point. This is pretty hard baked into the underlying EmailMessage class and you would have to override it non-trivially if you wanted to change that behaviour.
That said, I am not sure it is worth the effort. I don't know many email clients that show you the name that was in the To: field (given that, well, it's you), and in the absence of evidence to the contrary I would say that it can't be a key factor in spam scoring because most bulk senders out there just use a plain email address in the To: field.
I want append to Username into Cookie , so that the backend team will fetc the username from cookie.
So i tried to use the below code , but it dint append
<dp:append-http-request-header name = "'Cookie'" value = "concat('SM_USER=',$UserID) "/>
Where UserID contains value of username.
Is it right or anything else need to be added?
Take out the http-. The extension element name is dp:append-request-header.
It's one of those odd inconsistencies in DataPower extension naming. (They have been trying to deprecate the http-specific extension element names for some time now.)
When im trying to send a mail with django send mail only the html message is coming and not the normal message i want to know the difference between both.
Is there any best way to send mails through template or html files because i want a comming mailing system in my app.
Note:- the difference is of more important.
THIS IS WHAT I DID
msg_html = (' HELLLOOOOO')
msg_plain = 'Normalallalaa
send_mail("titleeeee", msg_plain,"sender#test",["reciever#tese",],html_message=msg_html)
My mail contained only Hello in bold
Where did my message go.
The problem is that some (old or specifically configured) email clients won't display HTML messages, therefore you need to make sure all your users can read your emails properly. If you decide to send just text, then users capable of getting HTML messages won't benefit from it.
This is the strategy I follow:
I use django.template.loader.render_to_string to render a template with a given context. The value this function returns is a string with a message in HTML.
html_text = render_to_string(template, context)
Then I create a plain text message based on the HTML message (for instance, by using a package named html2text):
plain_text = html2text(html_text)
And finally I send the email with django.core.mail.send_mail, passing html_text and plain_text as parameters.
Message is plain text, while html_message is a message formatted using HTML. If you set both, probably your email client is displaying the HTML version.
I was looking to find an answer to my question, but so far I got this:
https://graph.facebook.com/the_user_id?fields=name,picture
I need to be able to display/print first,last name and picture of a set list of users for which I know their ID. What code is required to get this data and then to publish it on a php/html page? Of course, this will means that if I want to show 10 users, I will input 10 different IDs (read smtg about an array list?). Notice that I DO NOT require for this to work for the current user.
Thanks in advance for your replies.
You need to use file_get_contents ( http://uk3.php.net/file_get_contents ) or curl in php and issue a request to the url such as follows:
https://graph.facebook.com/?ids=id1,id2,id3&fields=name,picture
(replacing id1,id2 with your ids)
this will then return you a json object. You then need to decode ( http://uk3.php.net/json_decode ) and loop through this and access the information
this should get you started
// people array uses the users id as the key and the dessert as the value. The id is then used in the query to facebook to select the corresponding value from this array
$people = array("id1"=>"favourite "dessert", "id2"=>"favourite dessert", "id3"=>"apple pie");
$json = file_get_contents('https://graph.facebook.com/?ids=id1,id2,id3&fields=id,name,picture');
$json = json_decode($json);
foreach($json as $key=>$person){
echo '<p><img src="'.$person->picture.'" alt="'.$person->name.'" />';
echo $person->name.'\'s favourite dessert is '.$people[$person->id'];
echo '</p>';
}
I've batched the requests here, alternatively you could perform 10 separate queries for each user, but that would be a bit pointless and inefficient
The easiest way is with an FQL query:
SELECT first_name, last_name, pic, uid FROM user WHERE uid IN
(Known_ID_1, Known_ID_2, ... Known_ID_n)
The easiest, if you're using PHP is to install the PHP SDK, though you can also make a call directly to https://graph.facebook.com/fql?q=URL_ENCODED_QUERY