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

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

Related

Office 365/Exchange Online Mail rule triggers twice when 2 internal recipients receive mail

I am having an issue where we have a rule set up to catch all mail coming in from a specific address and BCC the email off to 2 external addresses.
The rule is set up like this
If the message...
Is received from 'email#example.com'
Do the following...
Blind carbon copy(Bcc) the message to 'external#domain1.com' and 'external#domain2.com'
The email from email#example.com is sent from a web form and addressed to auser#mydomain.com and asharedmailbox#mydomain.com.
When the mail comes in, it is BCC'd twice to the external addresses and 1 copy only delivered locally in user and sharedmailbox.
This is all reflected in a message trace.
Has anyone come across this and knows how to prevent this?
TIA
Someone else in my organisation found out how to work around this.
They added in a condition to the "If the message" operation as below
If the message...
Is sent to 'auser#mydomain.com'
And Is received from 'email#example.com'
Do the following...
Blind carbon copy(Bcc) the message to 'external#domain1.com' and 'external#domain2.com'
And now the rule only processed once.

Mutt Send Signature Hook

I've got a send hook setup in Mutt for my signature. I usually have a few links in my sig that one customer of mine doesn't like, their email always spits it back. So to fix this I made a new signature file just for this client and setup a send hook in mutt that when it's going to this client it adds this special signature:
send-hook "~t #domain.com" set signature=~/.mutt/branded.sig
set signature="~/.mutt/sig"
The problem now is that once I send an email to this customer then all other emails even if they go to another email address now have the new signature.
How do I tell Mutt that anything other than that email gets the regular signature?
Instead of that second "set signature" line, you want to set another send-hook for "anything other than that".
For example:
send-hook . set signature="~/.mutt/sig"
send-hook "~t #domain.com" set signature=~/.mutt/branded.sig

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.

email not proper in rails 3

I've same problem like here. But still not able to solve it.
I've followed steps from here. but doing so doesn't sends mail.
The log file says: Mail is sent. but at the other side mail is not received.
Any ideas why?
Check your SMTP settings and make sure you have defined the right settings for your e-mail host. If you are using a sender e-mail other than Gmail then your settings will be different to the ones used in the Railscast.
The file to check is here: config/initializers/setup_mail.rb.
Edit: It still may be possible that the settings you used in jsp may not match perfectly with the 'phrasing' that Rails expects in the setup_mail.rb file. I have frequently come up against this problem where a slight difference in what SMTP settings you mention / don't mention / how they are worded will determine whether the e-mails send/receive or not.
If your logs show the e-mail is sending to a valid e-mail address (and you are not receiving those e-mails in your inbox or spam filter) then the problem, as far as I know, is most likely to be your SMTP. My advice is to check online for the Rails-specific SMTP settings for your e-mail provider, or in the case that you cannot find them, try different combinations until you find the correct one.
Okay the problem is solved. Problem was my file corresponding to action was not at proper place. Here is quick view on how to do it:
Add following to actionmailer:-
def send_mail
attachments['1.pdf'] = File.read('c:/1.pdf')
mail(:to => "harsh#xyz.com", :subject => "xyz", :from=>"harsh#xyz.com")
mail.deliver
end
Notes:- Make sure that the smtp settings are correct and the file corresponding to the action (In this example send_mail.rhtml) is present under appropriate folder.

Embed indentifier within an Email

I am trying to embed an ID into an email so that when a recipient replies to an email that my system sends out, my system can pick it up and match the two together.
I have tried appending a custom header, however this is stripped out when the user replies.
I have tried embedding an HTML comment within the email, but outlook does not seem to keep comments when a reply email is created.
Worst case scenario, I can manually try and match the sent and received emails by time span or have a visible tag within the message body.
Does anyone know of a more elegant solution?
Thanks in advance
Email messages already contain such an identifiers, called Message-ID. And there's even a way to send which message you're replying to by sending that ID in a header called In-Reply-To. That's done by pretty much all email clients, that's how they usually do their threading.
It's defined in RFC 822 (yep that's pretty old) and probably re-defined and refined in more modern versions of that.
I have seen a method that includes a one byte image with a unique name that's linked to the user. When they view the email and download the images, your HTTP server will record a hit for that unique image. Of course the user needs to display images, but you can include a message in the body asking them to display the images. We actually include content in an image so they need to show images.
If your incoming e-mail can handle +foo or -foo suffixes, use that.
Many e-mail systems can route user+foo#example.com or user-foo#example.com
to user#example.com. You can replace foo with some kind of identifier.
Several mailing list servers use this for tracking bounces.
While I can't say for certain, my investigation in that sort of matter some time ago yielded the following "conclusion":
Headers are transformed a lot
Message bodies are transformed a lot
This is partly because, I suspect, of:
Need to protect users from malicious intentions
Need to perform "targeted marketing"
I have seen "unique codes" flying around in clear text in the email body but I would suggest having a unique identifier embedded in the return address instead.
The usual approach is to place the id in the subject line and/or somewhere visible in the message text and informing the recipient that he should not modify the subject or quote the original mail when responding.