Content-type issue for email attachments mule - email

I'm using Mule's IMAP connector to read email attachments. I pretty much follow this. It all works fine, but my problem is that there are couple of end users who now tend to send the emails with attachments to us, but with Content-type as 'text/csv' or 'application/octet-stream' in which case Mule is unable to recognise/parse the attachments. The email client like outlook has no problems downloading the files. But does not work with Mule code - probably, the content-type to be blamed but is there a way I can get over this without demanding a change from the end user?
Here is the code that reads the attachments:
<expression-transformer doc:name="Read Attachments and set them as payload"
name="returnAttachments">
<return-argument evaluator="attachments-list"
expression="*" />
</expression-transformer>
<imaps:inbound-endpoint host="${email.server.host}"
port="${email.port}" responseTimeout="10000"
doc:name="IMAP" connector-ref="IMAPS" password="${email.pwd}"
transformer-refs="returnAttachments" user="${email.user}"
disableTransportTransformer="true" />
<!-- The code below does not work when the emails arrived have content type other the "multipart/mixed"-->
<set-variable variableName="fileName" value="#[groovy:payload.name]"
doc:name="fileName" />
As mentioned this one recognises the email and attachments when the content type(header) of the email is "mutipart/mixed". Does not work otherwise. Should I be asking the client to set the content type ?

Your question does not explain what exactly you're trying to do. You can send anything through e-mail. Each attachment is marked with a corresponding MIME type to indicate what sort of data format it contains -- is that an image, or a ZIP file, or perhaps a PDF document?
What is your application doing, and what reaction do you expect when I send, say, a holiday picture as an attachment? What should it do if I attach my bank's statement?
These questoins are about the business logic, about the real purpose of your project. This question does not contain any data about that, unfortunately.

Related

How do I forward a mail message as an attachment in MS Graph?

I'm retrieving all the messages from a given mailbox, and if one of them contains problematic attachments, I want to send an email to the sender of that message, explaining the problem, and including the original email as an attachment.
I need to either put the message into a stream, or save it to the filesystem. I imagine the former would be better, but I can't see any methods that can do that.
How big are the attachments that you want to forward? With the Graph there is a 4MB limit that you will hit with some of the endpoints that will restrict the methods you can use to do this. Eg if all the Messages are under 4MB then you could either attachment them as an Item attachment https://learn.microsoft.com/en-us/graph/api/message-post-attachments?view=graph-rest-1.0&tabs=http but for your purposes you'll loose fidelity on things like Internet Message headers which won't help with working out what's gone wrong with the message. Probably what you want to do is download the message first as MIME https://learn.microsoft.com/en-us/graph/outlook-get-mime-message save it as an Eml file and then attach that file. If you need to deal with 4MB+ emails you need to check the size and use https://learn.microsoft.com/en-us/graph/outlook-large-attachments?tabs=http when necessary.

How to retrieve the .xml extension attachments from mail by using MailCore to Sample iPhone app

How to retrieve the .xml extension attachments from mail by using MailCore for iphone?
I used MailCore to download the attachments from my mail to my sample iPhone app. I getting Inbox subjects from my mail that subjects I sort to get particular mail subject and mail attachments.
The problem is I got particular mail subject but not attachments. I used below code to get attachments from mail but it's not working.
NSArray *Array=[msg attachments];
CTBareAttachment *ctbaratt=[Array objectAtIndex:0];
CTCoreAttachment *ctcoreatt=[ctbaratt fetchFullAttachment];
but I'm getting :
Array count is zero
Please share your ideas.
This could be for a few reasons:
1)It is possible that you're not downloading enough information about the CTCoreMessage. When making a request to download the CTCoreMessages you must specify what information you want by specifying the correct fetch attributes.
For example:
[core_folder messagesFromSequenceNumber:from to:to withFetchAttributes: CTFetchAttrEnvelope | CTFetchAttrBodyStructure]
should populate the information about the attachments.
When fetching a message from IMAP, the command will specify exactly what information it wants.
you can see what is being fetched by enabling MailCore Logging as follows:
MailcoreEnableLogging();
[core_folder messagesFromSequenceNumber:from to:to withFetchAttributes: CTFetchAttrEnvelope | CTFetchAttrBodyStructure];
MailcoreDisableLogging();
You will see commands of the format
<command number> <UID> <Command> (<requested structure>)
I imagine you will see something like this:
1 UID FETCH (ENVELOPE)
You should ensure that inside the () either BODY or BODY[2] or RFC822 as these will contain information about attachments.
When you see what is actually being fetched you can read the RFC, if you are dealing with mailcore and IMAP then it is well worth the investment in time.
2)Failing that, perhaps your CTCoreAccount and/or CTCoreFolder are not connected, thus preventing the CTCoreMessage from having a valid mailimapsession and being unable to download the attachment information. If an attribute inside a CTCoreMessage is not available then libetpan should download it on request. The fact that is it not suggests that your account or folder may be not valid or connected.

Emails sent through joomla go to SPAM folder

I am using the latest Joomla build for my website.
Allso we use a DNS record for having the mail delivered to our own server instead of the server on which the website is hosted.
I have used several contact form components, but every sent mail goes to my SPAM folder.
After searching hours on the web (and getting linked to this site frequently) i decided to make a new post.
It does not matter if i use the standard joomla forms, or any component.
Whenever a user fills in a form on my website, the email gets sent. The user receives a copy of its message, and i receive the message of the user. However, this message gets thrown in the spam folder, as phishing.
The sender of the mail always is: username#nameserver.i3d.net; namens; websitename
What do i have to change/enable/disable for this to work?
Thanks in advance.
Patrick.
(Sorry, I'm new to Joomla, but it uses PHP, so this may apply. Also this answer got a little long...)
It might be an issue with the email headers. A lot of email clients will automatically spam-box all mail where the address in the From: header doesn't match the envelope sender. As an analogy, you might not trust a snail-mail letter signed "Your Rich Uncle", mailed in an envelope with a Nigerian return address. Also if your envelope sender has a different domain than the one the email is actually sent from, that's another quick ticket to the junk bin. For more info about Gmail's message blocking policies (and general good practices), you can try this help page.
Here's some basic PHP email-sending code:
$to = $userEmailAddress;
$subj = $emailSubject;
$mesg = $emailMessage;
$headers = implode("\r\n",array(
"MIME-Version: 1.0"
,"Content-type: text/html;charset=iso-8859-1"
,"From: WEB_ADMIN_NICE_NAME <WEB_ADMIN#YOURSERVER.COM>" // *** 'From:' header
));
$from = "-fWEB_ADMIN#YOURSERVER.COM"; // *** envelope sender
if(!mail($to, $subj, $text, $headers, $from)){
//Some error handling...
}
On the first line I commented, you'll want to replace WEB_ADMIN_NICE_NAME with the name you want the email recipient to see (e.g. "Bill Gates"), and on both lines, replace WEB_ADMIN#YOURSERVER.COM with the actual return address (e.g. "da_boss#microsoft.com"). Note: whatever address you choose for the return address is where users' replies will be sent.
To reiterate, make sure both lines have the same return address (though the nice name can be anything you like), and make sure that the actual server sending the mail is in fact located at YOURSERVER.COM.
Lastly, I'm not sure where Joomla does its mailing, but if you're totally lost, you can try grepping with -lr for 'mail[[:space:]]*('.
there are several reasons that could make your email look suspicious to spam filters; to find out which head on to:
http://www.mail-tester.com
grab the email address and send an email from your website to it.
Then go back to the page and it will tell you what's wrong.
btw I'm struggling with the same issue,my problem being that on Joomla 2.5.9 apparently when you send html emails, a text-only copy is not added to the message, which is considered "spammish behaviour"
The problem is the i3d.net email address. My personal experience is that their network (31.204.154.0 - 31.204.155.255) is a significant source of spam and they do not action abuse reports. I suggest changing your hosting company.

How to send form contents anonymously via email

How do you send the content of a website form to an email address without disclosing the email address to the user.
Thanks!
PS: If at all possible, I would like this to be in HTML JavaScript Ok, anything I guess.
Not possible. You can however put a "fake" from header in the mail. You'll only risk it to end up in the junk folder.
HTML doesn't provide any functionality to send mails. You'll really need to do this in the server side. How exactly to do this depends on the server side programming language in question. In PHP for example, you have the mail() function. In Java you have the JavaMail API. And so on.
Regardless of the language used, you'll need a SMTP server as well. It's the one responsible for actually sending the mail. You can use the one from your ISP or a public email provider (Gmail, Yahoo, etc), but you'll be forced to use your account name in the from header. You can also register a domain with a mailbox and just register something like noreply#example.com and use this to send mails from.
Update: JavaScript can't send mails as well. Like HTML it's a client side language. You'll need to do it with a server side language. All JavaScript can do is to dump the entire page content back to the server side. jQuery may be useful in this:
$.post('/your-server-side-script-url', { body: $('body').html(); });
with (PHP targeted example)
$to = 'to#example.com';
$subject = 'Page contents';
$body = $_POST['body']
$headers = prepare_mail_headers();
mail($to, $subject, $body, $headers);
Update 2: if you actually want to hide the to header in the mail, then you'll need to use the bcc (Blind Carbon Copy) instead. This way the recipient addres(ses) will be undisclosed. Only the from, to, cc stays visible.
If you mean doing so on a client side, using mailto: link - you can not.
If you mean any way, yes - you submit the form contents back to your server, and have your back end script send the email.
You can do the form in HTML, but the posting will need to be done in a script. Even if you don't expose the email address, the script can be used to spam that email address. This is why you see captcha being used in such cases.
There are scripts available for most languages. Check to make sure their are no known security problems for the scripts. The original Matt's script in perl had problems, and the Perl community created a more secure version.

How to send an email from a webpage/webform?

What techniques are available for sending an email via a webpage or a form on a webpage?
I've got some background idea that you POST the form data to a script but I've don't really know what a cgi script is (I'd love to learn if this is the suggested method!) or what the current practice is.
This is just to provide some way for users to contact the operators. The in-page form seems like it would be easier on the user than ask them to open their mail client. I was also concerned about bots harvesting the contact email address (in the case of mailto: links).
When you submit a form, the data in that form gets sent to the server-side script. For example, in PHP you access that data with the $_POST array, the <input name=""> becomes the arrays index.. For example..
// <form action="mailer.php">[..]<input name="subject" [..]><input name="content" [..]></form>
echo("The subject is: ". $_POST['subject']);
echo("The content is:" . $_POST['content']);
At the most basic level, all you have to do is use your programming languages built in mail function. Again, in PHP this is simple mail():
mail($to, $subject, $message);
You would just set $to to your email address (Do not allow the user to set this, or they are able to send mail as "you", to anyone - "spam"..), $subject and $message would be set form $_POST[]
Before you go any have a HTML file that goes to a script with mail("me#example.com", $_POST['subject'], $_POST['content']);, think what would happen if someone reloaded that page 200 times.. You must have some kind of security in it, probably a captcha, and/or rate-limiting.
One thing, that has bugged me before - remember a "contact us form" is not a replacement for giving an actual email address! For example, my mail client keeps a copy of all mail I send, and I can attach files, and it's much nicer writing in a familiar mail client than a form <textarea> (especially when the I accidently hit "back" and the form decides to clear itself)!
For most unix/bsd/linux systems, most languages provide a programmatic wrapper around the Mail command.
If you are using the ASP.NET 2.0, you can use the System.Net.Mail namespace.
More information here
todays languages for web development usually have libraries for sending e-mail. it depends which language you use, but you'd find it in your language's docs. it's pretty simple, the library inside your language usually encapsulates and provides 'smtp client' behavior which you use. you provide mail message with sender and recipient, and the data for connecting to your SMTP server.
or, you sometimes may use the SMTP capabilities on the machine where your web server is, if those are available. i'm not sure whether it gets worse for the e-mail at the recipient server because your server might not be recognized as mail server for the domain... someone with more experience might comment on that.
Well, here's what not to do:
Please spam me, kthx
It is a better code pattern to have users submit a form, sanitize the input and format it however you see fit, and then pass the data to a mail function in your language of choice.
Sending mail should be done server-side - the specifics change according to your server-side language, your operating system, and what access your server has to an SMTP server.
If you're looking for a lightweight way to add a contact form to a blog or public website, try Wufoo - you can add a contact form that will send you email very easily (up to 3 forms for free). I am not affiliated with them, I just think they're cool.