Python IMAP search using a subject encoded with utf-8

import imaplib import getpass email = “[email protected]” sock = imaplib.IMAP4_SSL(“imap.gmail.com”, 993) sock.login(email, getpass.getpass()) # select the correct mailbox… sock.select() # turn on debugging if you like sock.debug = 4 then: # use the undocumented IMAP4.literal attribute sock.literal = “réception” sock.uid(‘SEARCH’, ‘CHARSET’, ‘UTF-8’, ‘SUBJECT’)

How can you send mail using IMAP?

IMAP is a mailbox protocol. It does not (natively) support sending mail, only accessing it. In order to send mail you must use SMTP. Its possible that there is an IMAP extension for sending mail, and its possible that Google Mail supports that extension, but I doubt it. Hence, if you want to send an … Read more

How to configure trustStore for javax.net.ssl.trustStore on windows?

Actually all you need to do is use Windows-ROOT as trustStoreType. This will use built-in certificates so if anything works in your browser then it should work. Add to VM options: -Djavax.net.ssl.trustStoreType=Windows-ROOT -Djavax.net.ssl.trustStore=C:\\Windows\\win.ini Restart the server. Note! Probably any readable file can be used as a trustStore path. It’s not really used. You can also … Read more

Reading emails from Gmail in C#

Using the library from: https://github.com/pmengal/MailSystem.NET Here is my complete code sample: Email Repository using System.Collections.Generic; using System.Linq; using ActiveUp.Net.Mail; namespace GmailReadImapEmail { public class MailRepository { private Imap4Client client; public MailRepository(string mailServer, int port, bool ssl, string login, string password) { if (ssl) Client.ConnectSsl(mailServer, port); else Client.Connect(mailServer, port); Client.Login(login, password); } public IEnumerable<Message> GetAllMails(string mailBox) … Read more

PHP IMAP decoding messages

imap_bodystruct() or imap_fetchstructure() should return this info to you. The following code should do exactly what you’re looking for: <?php $hostname=”{********:993/imap/ssl}INBOX”; $username=”*********”; $password = ‘******’; $inbox = imap_open($hostname,$username,$password) or die(‘Cannot connect to server: ‘ . imap_last_error()); $emails = imap_search($inbox,’ALL’); if($emails) { $output=””; rsort($emails); foreach($emails as $email_number) { $overview = imap_fetch_overview($inbox,$email_number,0); $structure = imap_fetchstructure($inbox, $email_number); if(isset($structure->parts) … Read more

Downloading attachments to directory with IMAP in PHP, randomly works

This is perfect working answer, try this. This Sample run properly and download all the attachments with no issues. <?php set_time_limit(3000); /* connect to gmail with your credentials */ $hostname=”{imap.gmail.com:993/imap/ssl}INBOX”; $username=”YOUR_USERNAME”; $password = ‘YOUR_PASSWORD’; /* try to connect */ $inbox = imap_open($hostname,$username,$password) or die(‘Cannot connect to Gmail: ‘ . imap_last_error()); $emails = imap_search($inbox, ‘FROM “[email protected]”‘); … Read more