Change the displayname of the sender when sending mail via o365? - email

Is it possible to control the display name of the sender when sending mails with the office 365 OutlookServicesClient?
I.e., I want to use, say mailer#domain.com as the sender which is configured with the name some name#domain.com in office 365. But for a given mail I want the from name to instead be some other name#domain.com.
I've tried this:
Message draftMessage = new Message
{
Subject = subject,
Body = body,
ToRecipients = toRecip,
CcRecipients = ccRecip,
From = new Recipient()
{
EmailAddress = new EmailAddress() { Address = "mailer#domain.com", Name = "Some other name#domain.com" }
}
};
But the mail is still sent with the preconfigured name of some name#domain.com.
So, is what I want possible?

According to the reference documentation for the Message object, what you want to do is possible. However, logic tells me that shouldn't be possible, and furthermore, the testing I did showed me it wasn't possible (or isn't working). I will follow up on this and update this answer when I get a definitive answer, but at this time, it appears like you can't change the name of the sender (or it's broken).
UPDATE: The From property is writable. I've tested this using pure REST, so I can't speak exactly to what the client library you are using is doing, but I think the request is being transformed to prevent spoofing.
It is possible to control the display name of the sender, but you can only do so with other users in your Office 365 tenant. To do this, sign in to the Office 365 Admin Portal, go to Users, then Active Users, then select the user (User A) that you want to send on behalf of. Click Edit and select Mailbox Permissions. Add the alias or email address of the user (User B) who is running the code (the user authenticated with your app) to the first box under Send email from this mailbox. This will allow you to set the From property of a message sent by User B as User A.
I understand this isn't exactly what you were after, but having the ability to send email as any email address can lead to some bad stuff. Hope this helped!

Related

How to recieve email from Contact Us from written with Flask

I just created a Contact Us form using Flask. The code seems to work correclty as explained in many tutorials like this one: link.
The reason why it all works it is because at the beginning of the app file I need to insert the username and password of the person who is sending the mail (in this case it's me) through the form:
mail = Mail()
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = 'my_personal_email0#gmail.com'
app.config["MAIL_PASSWORD"] = 'my_personal_password'
mail.init_app(app)
However once my website will be hosted online in some server, whoever wants to contact me trhough the form will just have the option to insert his email in the form and of course no password. Here it is what it looks like:
                               
Would you be able to explain how this situation is handle once I host the website in some server? Is there something wrong with my logic?
You can do 2 things here
You need to store the details in the database and make an admin panel to view the details from the database
Create a fake Gmail and let that Gmail send you the users name, email subject, and message
I personally prefer the 1st option

google sheets email script not runnable by all shared people

I have a google sheet shared with other people (I'm the owner) and in it there is a button linked to a corresponding bundle script that send me an email when the user logged press that button (so if I click the button I send an email to me).
All the other people have the "edit" privileges but when they click the button an error occurs saying that it's impossible to send the mail (when I click all works perfectly).
The accounts associated to the other people has the same email domain of mine (not gmail, but related to the same company).
It seems like that the script has different privileges because I have no problem, while the other people do.
As normal, at the first time they click to the button they (but also me) had to accept the google authorization to "send email as you" (as the avatar of the current account logged).
This is the code of the button:
'''
var sheet = SpreadsheetApp.getActiveSheet();
var sel = sheet.getSelection();
var sel_range = sel.getActiveRange();
var message = sel_range.getValues();
// get task IDs
var prev_values = sel.getNextDataRange(SpreadsheetApp.Direction.PREVIOUS).getValues();
var cod_tickets = [];
for (var k in prev_values){
cod_tickets.push(prev_values[k][0]);
}
var emailAddress = SpreadsheetApp.getActive().getSheetByName('Manager').getRange('I2').getValue();
var subject = 'ticket ' + cod_tickets;
MailApp.sendEmail(emailAddress, subject, message);
'''
I say that they send an email to me, because the "emailAddress" variables will be filled with the value of the cell that contains my email address.
Any ideas?
Have a look at the documentation for restrictions for simple triggers:
They cannot access services that require authorization. For example, a
simple trigger cannot send an email because the Gmail service
requires authorization, but a simple trigger can translate a phrase
with the Language service, which is anonymous.
Solution:
Use an installable trigger instead.
Go to Edit->Current Project's trigger
Click on +Add trigger
Select event type On edit.
Your function should no be named onEdit, because otherwise both the simple and installable trigger would fire at once which can lead to problems.
The problem:
The installable trigger will fire for every user, but it will fire on your behalf, so the email will always be you.
If this is a problem, you will need to use a service account that will impersonate the session user, which will make things more complicated.

how can i get avatar (profile picture) of email id in gmail addon

I want to read a particular thread of email and get its email ids, in to,from,cc.
also I want to get their profile pictures and name to display in the addon.
I tried to get using metadata but was not able to get it
Note : I am able to get the email ids.
but for some I am not getting the names.
I am not able to get profile pictures for all
so i need a way by which i can get profile picture and name of all email ids
It’s only possible to get your own profile picture
as you do not have permission to access someone else’s. So if you’re deploying an
addon, the user will be able to see their own
profile pic.
As far as getting the name, not quite sure what you mean. The full name of a contact? The name of the the person sending you the email?
To get the name of someone that’s sent you an email that’s not one of your contacts, it’s not possible. For a contact that emails you, it’s quite simple. Here is the reference for the ContactsApp: first grab the contact by the email address, and then on the contact object, there is a method to get the fullName.
https://developers.google.com/apps-script/reference/contacts/contacts-app
So far it's not possible to get the profile picture. However, it's easy to get the contact name.
Here an example:
function onGmailMessage(e) {
var messageId = e.gmail.messageId;
var accessToken = e.gmail.accessToken;
GmailApp.setCurrentMessageAccessToken(accessToken);
var message = GmailApp.getMessageById(messageId);
var name = message.getFrom(); // This function return the name of the sender
}
If you need more information about all methods that you can use just have a look to the official documentation.

How to send email by simple email address using crm?

I'm working with Dynamics CRM 2016, I want to send an Email from crm using an email address that the user insert (the email Id is taken from a field in incident-Entity and not from crm-user) according to examples online the option is to use entityreference from another entity that will hold and get the Email address, is there a way not to use Entityreference but instead get my email address from a simple field on incident form?
You can use e-mail addresses that are not associated with e-mailaddress fields. It just requires a few steps.
In the UI navigate to Settings > System Settings > tab Email > header "Set Email form options".
Make sure setting "Allow messages with unresolved email recipients to be sent" is Yes.
Now you can use literal e-mail addresses like in this example:
var sender = new EntityCollection();
sender.Entities.Add(new Entity("activityparty")
{
["addressused"] = "me#home.test"
});
var recipients = new EntityCollection();
recipients.Entities.Add(new Entity("activityparty")
{
["addressused"] = "info#acme.test"
});
var eMail = new Entity("email")
{
["from"] = sender,
["to"] = recipients,
["subject"] = "Just a test",
["description"] = "Body of your e-mail"
};
organizationService.Create(eMail);
You can do it programmatically! You can send an email to a person who is not a Lead/Contact/Account.. The CRM will send email but it will show un resolved referenced when you open it in CRM
Update:
but instead get my email address from a simple field on incident form?
This is not possible in CRM UI. But possible using the code snippet from the blog link in comment. You have to query the textbox content and put in recipient party address.
(These two lines are for sending email to activity party email Id from associated record non-email field from CRM UI, without any code or customization for this particular scenario)
Unfortunately you cannot achieve it.
Only way is associated record.

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.