MailKit: How to check if a sent mail has been added to the "Sent" folder? - mailkit

When I send an email using MailKit, I need to ensure that the email is added to the Sent folder.
Some email servers, like Gmail and Outlook, seems to automatically add the email to the Sent folder. In other cases, I manually locate the Sent folder and add the email.
Currently, I have hard-coded the server to skip the Sent folder addition step if the client is using Gmail or Outlook, but that is obviously a very hacky solution.
Is there a way to check whether a sent email has already been added to the Sent folder, or if I need to do it myself?

You could check the Sent folder for a message that has the same Message-Id header:
var uids = sent.Search (SearchQuery.HeaderContains ("Message-ID", message.MessageId));
if (uids.Count == 1) {
// looks like the message was added
}

Related

Jenkins: Emails not being sent from email-ext

I'm trying to send emails from Jenkins using the groovy script. My problem is that emails are going to some distribution lists while they're not going to other DLs. Here is a code snippet:
emailext (
subject: subject,
body: content,
to: 'a.b#x.com, c.d#x.com, #d.e#y.com, #f.g#y.com'
)
The emails are being sent to the IDs a.b#x.com, c.d#x.com, #d.e#y.com but no one in #f.g#y.com gets the email.
I'm sure there's no spelling mistake or typo in my to list as when i open the email on outlook, i'm able to expand the #f.g#y.com to see all the members.
What am i missing out on?

Send a text in message body and not as an attachment

I'm sending the email message from ABAP-report of SAP ECC 6.0 EHP5 to Microsoft Exchange via SMTP. The message reaches user's inbox in Outlook 2013, but it arrives as an attachment instead to be in the body of the message. From the code's point of view, I'm sending the plain text, and I'm expecting to get it inside the message. Since I'm using the default ABAP-approach to sending emails, which sends text inside of an email body, I suppose that the root of the problem is in Exchange/Outlook side.
Is there any Exchange/Outlook setting, which explicitly directs to send the message as an attachment or inside of the message body?
In the examples given, the body is always typed HTM. For the mail body I always use type RAW and this works just fine (with Lotus Notes). So maybe you try the following when creating your mail body:
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = im_text
i_length = txt_len
i_subject = im_subject ).
No, Outlook/Exchange doesn't provide anything for that. I suppose the issue comes from the ABAP/SAP software.

How to use applescript to tell Mail to keep a copy of sent message

I use AppleScript and can send messages without any problem, but the "Sent" box does not get a copy of what I sent. However, if I use Mail Application to send messages, the "Sent" box gets a copy of what I sent. So I guess my AppleScript may miss a command or so to tell Mail to keep a copy of the sent messages. What's the command that I missed? Thanks.
tell application "Mail"
set theNewMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return, visible:true}
tell theNewMessage
set visibile to false
set sender to theSender
make new to recipient at end of to recipients with properties {address:theAddress}
make new attachment with properties {file name:theAttachment} at after the last paragraph
send
delay 5
end tell
end tell
I don’t think you’re missing any command. I copied your script to Script Editor on my iMac, set values for theSubject, theBody, theAddress, theSender, and theAttachment, and ran it. It (a) successfully sent the message, and (b) I was able to view the message it sent in my Sent mailbox.
I tried this both with a known sender and with a random example.com sender. In both cases, it was saved in the default Sent box.
So the issue most likely lies elsewhere. Make sure that the value you’re currently using for theSender maps to an account in Mail that saves sent messages. (If it’s an IMAP account, it may be saving sent messages on the server, and server behavior may be affecting what you see.)
If that doesn’t work, set up some test values for all of the variables in the script except theAddress (using example.com for theSender), and include those (except theAddress) in your question. (If you can use example.com for theAddress, too, do that, but some servers will simply refuse the message immediately, which makes it worthless for testing this particular case.)
Note that you have an error that does not change this behavior; you have “visible” misspelled as “visibile”. However, I tried it both ways and in both cases the outgoing message does get stored in the appropriate Sent box.
Try adding this after you send the message...
set accountReference to first account whose name = "my account name"
synchronize with accountReference

SMTP MAIL FROM: being received as DATA: From?

I'm writing a recreational email spoofing app with several safeguards to make the app useless to spammers and other malicious people. One of these safeguards is that the app requires the user to send emails from the user's own SMTP account. The app is supposed to use this "login#smtp.example.com" for the MAIL FROM command. The From: field visible to the user is supposed to be spoofedAddress#example.com. I'm using Apache Commons Net SMTP. Here are relevant code fragments.
AuthenticatingSMTPClient client = new AuthenticatingSMTPClient();
....
client.auth(AuthenticatingSMTPClient.AUTH_METHOD.LOGIN, "login#smtp.example.com", "password");
....
client.setSender("login#smtp.example.com");
....
SimpleSMTPHeader header = new SimpleSMTPHeader("spoofedAddress#example.com", "Addressee#example.com", "Subject");
....
When the email arrives in my inbox, it displays "login#smtp.example.com" in the both the From: field and the envelope. "spoofedAddress#example.com" is nowhere to be seen. I used Log.e("SendMail", header.toString()); to show me the header produced by my app and it was correct. It appears that my email client is ignoring my header in favour of the envelope.
Solution
My SMTP server was intrusively editing the From: field. When I told my app to connect to a different SMTP server, "spoofedAddress#example.com" appeared in the received email's From: field.

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.