I use mailkit pop3 to fetch emails, but I find it didn't fetch newest emails and each time I run it return different messages count number
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostname, port, useSsl);
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate((username), password);
int messageCount = client.Count;
// var folder = client.;
// We want to download all messages
List<MimeMessage> allMessages = new List<MimeMessage>(messageCount);
for (int i = messageCount - 1; i > 0; i--)
{
var msg = client.GetMessage(i);
allMessages.Add(msg);
}
}
I supposed that all messages variable should be filled with all emails ordered from newest emails to old emails but I found all messages return old emails and not contains at all new emails at all, I searched a lot and didn't find the reason, Do you know why that happened and how can I fix that ?
I wish to find any help here and Thanks in advance
Are you connecting to GMail, by any chance?
This is a GMail behavior where, depending on your POP settings (as set in the GMail web app Settings page), will determine what messages the client sees.
This is not a MailKit issue.
From Google's own FAQ in the section titled "Emails aren't downloading correctly", it states:
After you set up POP in your Gmail settings, your emails become available
in batches. It might take a while to see all your emails.
Note: Gmail downloads a copy of every email you send or receive, except
for emails in Chats, Spam, and Trash. To avoid duplicates, Gmail doesn't
download emails sent within your mail client, but you can still see them
if you log in to Gmail.
If you continue to have problems downloading emails, try using recent
mode:
In your email client's POP settings page, find the "Email address" or
"User name" field.
Add recent: in front of your email address. For example,
recent:example#gmail.com.
If that doesn't fix the problem, try deleting your Gmail address from your email client, then re-adding it.
Related
I can send mail with a valid Office365 account using my C# web application to a list of opt-in addresses. So it is our own data source with our customers in it. The problem is that it is probably not received by our customers. I have send a mail from the info account to my own office365 account and pasted the headers in mxtoolbox and got a message that my local pc is blacklisted. even when it is using the smtp of office365. We have dkim enabled and spf in the dns. What else should I do to troubleshoot this?
Here is my simple C# code for sending the mail (which works, but might needs additional anti-spam stuff?)
SmtpClient sc = new SmtpClient();
sc.Host = "smtp.office365.com";
sc.Credentials = new System.Net.NetworkCredential(SmtpUsername, SmtpPassword);
sc.Port = 587;
sc.EnableSsl = true;
Should I add my home IP and from the office to the SPF dns entry, even when I am using the smtp of office365?
this is the value for Authentication-Results
dkim=none (message not signed) header.d=none;ouroffice365domain.com; dmarc=none action=none
Is that the cause for getting on the blacklist? Please note that I am not trying to send spam. It is a valid data source where people opted in for. We are just migrated to office365 and need to send a mailing to our customers from our custom web application. We are aware of the limitations (10k per day) and 1 mail every 2 sec.
edit will change this: https://stackoverflow.com/a/23409351/169714 because I just used the mail address and not the first and last name of the customer.
Not having DKIM setup is not going to get you blackisted, having it set up improperly can. Your HOME PC should have nothing to do with SPF, it's the lasting sending IP which should be OFFICE 365 IP. Did you validate your DKIM and SPF by sending an email to mailtest#unlocktheinbox.com or check-auth#verifier.port25.com?
I also don't think your LOCAL PC is blacklisted, it's the IP of your INTERNET Provider that is blacklisted. Unless you have a static IP it will change.
I am currently using an Office 365 account to send email from various websites. I have implemented an smtp client in both php and C# to send the mail. I use GoDaddy and Rackspace to hosts my sites.
The mail reaches most address without issue, however, I have a business domain through Google, which ends with .co, and emails do not make it to my inbox there.
Here are the settings for the PHPMailer client:
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPSecure = "tls";
$mail->Host = 'smtp.office365.com';
$mail->SMTPAuth = true;
$mail->Username = '<myuser>';
$mail->Password = '<mypassword>';
$mail->Port = 587;
$mail->setFrom('noreply#<mymaildomain>.com', 'MyMail');
The settings send email find to yahoo, gmail, etc. However, when I try to send it to my .co email address, the client indicates the mail was sent, but it never shows up in the inbox.
I am wondering if it is an issue with a domain in Google or if the .co is the problem. Is there any special setting I need to make on the client for .co addresses?
UPDATE
I changed phpmailer to simply use php's mail function. The mail was sent through to my .co domain, but I still have no idea why it will not go through when an authenticated SMTP user sends it. I can go into my Office 365 account and send email to the .co address without issue. I just cannot push it from the server. My host server does not contain the smtp server.
We have used Faxmail.com to send fax (Email to fax) from one of our ASP.NET application, and it has been working from ages, suddenly its failing to send fax if the file size is more than 250 KB. We have been sending fax with file size up to 8 MB with same application before.
Eg :-18180000000#faxmail.com
Send the email message from SMTP to the desired fax user and it used to deliver to fax machine.
SmtpClient smtp = new SmtpClient();
MailMessage nm = new MailMessage();
smtp.Host = "smtp.domain.com";
smtp.Send(nm);
We don't see any exceptions while sending email, however its not reaching fax machine (receipient).
Note :- This was been working since early 2000.
You might want to start by checking your mail server logs. These should show whether or not the message was delivered to faxmail's mail server - and if so, you should see a receipt acknowledgement from faxmail's mail server. If the record shows successful delivery, then you can forward the record to faxmail, and they should be able to troubleshoot to find the reason that the message wasn't processed by their system. If the mail server logs show an error delivering the message, there should be a description that you can go on to troubleshoot. If you don't find a record at all, then it means the problem is on your end - the message is getting dropped somewhere before it is sent.
We found the issue was at the easylink server which is the service provider for faxmail.com. Easylink was failing to render the PDF attachment that was being sent. Upgrading the server with latest PDF patch resolved the issue.
I am trying to implement an application which can receive the mails sent to a specific email address. The scenario is that the user will send a .ppt file as an attachment to a specific email address, and my WPF application will listen to this email and once it receives the email, it will download the attached file - saving it to the hard drive.
I looked a bit, but all I found was the System.Net.Mail objects which only support sending emails through an application using the System.Net.Mail.SmtpClient class.
How can I do this in C#?
var client = new POPClient();
client.Connect("pop.gmail.com", 995, true);
client.Authenticate("admin#bendytree.com", "YourPasswordHere");
var count = client.GetMessageCount();
Message message = client.GetMessage(count);
Console.WriteLine(message.Headers.Subject);
A simple tip, that you can follow:
https://joshwright.com/tips/tips-sending-receiving-email-in-csharp/
You can use POP3 or IMAP to check for email messages and then process the email message for saving the attached .ppt file. Click here for a sample.
Using the OpenPOP .net client for getting messages from Gmail.
I'm wondering how I can get only the new messages?
Currently, I get the atom feed and then get as many emails as the feed has with the OpenPOP client (starting from the first).
GmailAtomFeed feed = new GmailAtomFeed("user", "pass");
feed.GetFeed();
int unread = feed.FeedEntries.Count;
POPClient client = new POPClient("pop.gmail.com", 995, "user", "pass", AuthenticationMethod.USERPASS, true);
for (int i = 0; i < unread; i++)
{
Message m = client.GetMessage(i, false);
// ...
}
Is there a better way to do this?
And how do I set the unread messages to be read?
I doubt you can do it with pop3. From my understanding POP3 doesn't support the notion of the unread\unseen email. It should be up to the client to track messages which were already shown to the user and which were not.
What you can do is switch to using IMAP protocol to access gmail. Check this link for how you can switch it on for your gmail account Getting started with IMAP for Gmail.
Now, if you're using c# there are some commercial libraries for IMAP and there free\opensource ones: like this one on codeproject: IMAP Client library using C#. What you have to do to get unseen messages is to specify "unseen" flag for the select command. Here's an example
You have to store the UIDL of each email in a local database. When you want to check for new mail, you retrieve the UIDLs on the server and see if you have if already in your local database; if not, it's a new mail.
Outlook uses the same strategy.
same Q How to retrieve only new emails using POP3 protocol