I have heard that is better to never click to any link in an email. Is it a bad idea to click to a unsubscribe link? What is the best way to unsubscribe to undesired mails?
You should not click on any links. By clicking on the "unsubscribe" link you probably get marked as "Active Reader" which is willing to interact. You also get on the page of the sender, which might could infect you with malware.
Remember: With clicking on any link you've confirmed to the sender that your email address is both valid and in active use.
Just delete and ignore it. Your email then might get marked as "inactive".
I think the one thing the others (as of this post) hasn't mentioned: Source of the spam
I would say you should differentiate between "Good" spam (Something you signed up for - knowingly, accidentally, "opt-in" purposely, "opt-out" not clicked)... And "Bad"/"Unknown" spam (random garbage that likely uses the click for tracking).
I have no issue clicking "unsub" from Lowe's email (I signed up for "Weekly Specials" when I got my Lowe's Card. Then later, I realized I don't want those emails)... but I wouldn't click on "CH3@P V1@GRA!!!" unsub links.
One is someone you KNOW should have your email and you know they know you are active. The other is someone who probably doesn't know you are active - until you click that link.
Edit: As mentioned in comments: There is Good and Bad spam, but sometimes you are unclear. I've had the same gmail address for 10+ years now. Lots of stuff comes in. Personally, I have a good idea of what spam I'm supposed to get (News letters, stack notifications, facebook updates, bill reminders, etc)...
I also kinda know whats outside of the normal. Normal has changed as I've been actively "unsubbing" from stuff I expect because I don't read it anymore (largely due to changed job and changed newsletter reading), but I still have an idea of the expected ebb and flow.
If I'm unsure, I err on the side of not clicking in the email and instead click "mark as spam". This keeps me with two buckets: Good and Bad(/unknown).
It's pretty much a coin toss. If the spammer is a honest one, you'll get unsubscribed. If he's a malicious one, you'll get marked as "active reader" and get enrolled in even more spam lists.
The second option silently assumes that it's actually worth the spammer's time to keep track of "good" and "bad" recipients, that is, that having a tracking system is more cost-effective than simply sending more spam. That may or may not be true. You have to decide that on your own.
I'd disregard the "you may get infected" argument, because it's not a threat exclusive to spam - you should keep your browser updated and ignore install requests all the time, not just sometimes.
I personally tend to ignore spam and wait for mailbox provider to update their filters. But I do believe that many unsubscribe links are legit because few times they've worked for me.
In addition to being marked as an active reader as @Danny says, unsubscribe links could be used to infect your system with malware. If you actually subscribed to the site and want to unsubscribe the best way to do it is log into the site and change your preferences. Otherwise report it as spam and delete it.
If you know the sender has got your email address legitimately, as per @WernerCD's answer ('Something you signed up for - knowingly, accidentally, "opt-in" purposely, "opt-out" not clicked'), go to their website and unsubscribe there.
Many companies use third party web sites as end points for the unsubscribe links ("mailbot.com/unsubscribe" as opposed to "company.com/unsubscribe") in their emails, making it virtually impossible to know whether it's actually spam or not. The company already has your email, so they will definitely continue spamming if you don't do anything, and would have shared your email already if they are so inclined. Of course, their unsubscribe functionality may not work, at which point you should just treat them as another spammer.
I use hotmail (live/outlook...) and in their web client, at the bottom of each email they have an unsubscribe button, it is not part of the email it's within the mail client and this button will unsubscribe you from sources which they trust and have set up this system with.
If the source is not trusted they will simply block them from sending you further mail.
This works well in both scenarios, and if you use a different provider there should be a way to block senders.
In the USA, there is the CAN SPAM act which requires advertisers to honor and respect unsubscribe requests. Violating this is a very serious crime. You can report it easily to the FTC, and if it's a US company, they will get into a lot of trouble. Because of how bad the punishment is, legitimate companies rarely disregard unsubscribe requests - you can safely unsubscribe from those (and in fact it's better because you don't pollute the spam filter with non-spam data).
With shady companies that use the unsubscribe link as a trap, of course it is a bad idea, they will just send you more spam and sell your email for more money. You can usually figure out easily if a sender is legitimate - just look at the TLD, if it's a .com check the WHOIS, see if there's a physical address anywhere on their site or in their email. Getting "respectable" TLDs like .com is pretty hard for spammers, because they will quickly get reported for abuse and registrars will punish them. They prefer obscure TLDs like co.cc where the abuse prevention doesn't work very well.
But if you are getting a promotion from Target because you bought a pair of shoes there last week and gave them your email, of course they're not going to keep sending you spam after unsubscribing. Getting slapped with criminal charges just isn't worth it for them.
Be careful about clicking links in dodgy spam. They stuff a unique per-mail ID into every link (usually will look like
www.buythesedrugs.com/store?id=baef8f6785b26c986d29) - if you click that link, even if it's nothing to do with unsubscribing, the spammer can see what email that id was sent to and deduce that you are getting and reading his mails. If you manually remove the id, and go to just
www.buythesedrugs.com/store you will be fine (but don't enter your email anywhere).
My experience with such links is that the amount of spam that I receive tends to decrease when I click on such links. Although most such links go to a similar/identical page as each other, I am of the opinion that those links are provided in order to legally cover the spammers - because anyone sending email has a legal obligation to stop sending at the recipient's request, thus they are legally covered as they have provided a way to request to receive no more emails from them. In order to reduce the number of people who unsubscribe (and thus increase the number of people that they can continue spamming) they make the links difficult to find. That's my experience anyway.
If you are using Gmail it should be safe to click
Unsubscribe link right after the "from" name in the Gmail interface. Google tries to validate senders and show
Unsubscribe only for senders with a high reputation:
We won't provide the unsubscribe option on messages from spammers: we can't trust that they'll actually unsubscribe you, and they might even send you more spam. So you'll only see the unsubscribe option for senders that we're pretty sure are not spammers and will actually honor your unsubscribe request. We're being pretty conservative about which senders to trust in the beginning; over time, we hope to offer the ability to unsubscribe from more email.
See also this relevant question on StackOverflow.
What is the best way to unsubscribe to undesired mails?
Sometimes I begin getting spam from sites where I have never registered or subscribed to receive their newsletters. This looks weird to me because I can recover password from these sites, login and change subscription settings while I have never registered on them. This is some sort of "Good" spam as @WernerCD says.
In this case I usually alter my subscription email address to any free disposable email address such as ThrowAwayMail.com or 10minutemail.com (I can do it after logging in). I guess that it is better way of unsubscribing because chances are my real email will be completely deleted from spam list.