I send 200 emails to a community of students via a google-spreadsheet attached google script.
My mailing call is as follow :
MailApp.sendEmail(
"toto#gmail.com", // targetEmail
"HELLO FROM KING OF NIGERIA", // emailTitle
"", // something
// emailContentHTML
{ htmlBody: "<b>Hello John</b><br><p>I'am king of Nigeria.<br>Got gold everywhere.<br>Need your help I'am in danger.<br>Want to share with you.<br>Could you send me 50$<br>Sinceraly, your friend.</p>"}
);
The script being run by my google account john.Doe#entreprise.com, the 200+ participants see the email as coming from me (john.Doe#entreprise.com). I understand this is fair game to limit spamming and co, but my company has a gmail entreprise.com domain name and I would like a solution so to not get dozens of "Thanks you" alerts in the following days. For sure, I do NOT want them to keep me in their following discussion.
So I look for something such as create a no-reply#entreprise.com account, and then a js thing so the script sign email with this no-reply#entreprise.com email.
Also, is there a way to programatically sign the google-script mailing from an other account of my company (no-reply#entreprise.com) ?
Note : google-script-manual
Since the script is being run under your Gmail account, the easiest way to do this is to add noReply: true to the message object. This will result in the email being sent from a generic noreply#enterprise.com email. The noreply email account does not need to be created for this to work.
Note that this does not work for personal Gmail accounts.
The documentation for this is at this link as noted in Edward Wall's answer.
MailApp.sendEmail(
"toto#gmail.com", // targetEmail
"HELLO FROM KING OF NIGERIA", // emailTitle
"", // something
// emailContentHTML
{ htmlBody: "<b>Hello John</b><br><p>I'am king of Nigeria.<br>Got gold everywhere.<br>Need your help I'am in danger.<br>Want to share with you.<br>Could you send me 50$<br>Sinceraly, your friend.</p>",
//send from generic noReply#enterprise.com address
noReply: true}
);
You could use the following method from the MailApp documentation
sendEmail (title, replyTo, subject, body)
Setting the replyTo to your do-not-reply email will mean that anyone who presses reply will send their email to your do-not-reply mailbox
MailApp.sendEmail (
"email#example.com", // targetEmail
"do-not-reply#example.com", // reply to email
...
)
Link to MailApp Documentation
The easiest way to send email from the no-reply#enterprise.com account is having the Apps Script will have to run under the authority of that account.
How you achieve this depends on how the script is being executed. If it is being executed by a Trigger, the Trigger must be created by the no-reply account.
If the script is published as a web-app, it should be deployed from the no-reply account, and set to execute as no-reply#enterprise.com.
If the script is triggered manually, it will have to be triggered by somebody logged in as the no-reply user.
A simpler option is to set a reply-to address, as shown in Edward Wall's answer.
Related
I am using NSSharingService to prepare an email with attachment for the user of my macOS app. My code is:
let emailService = NSSharingService.init(named: NSSharingService.Name.composeEmail)
if emailService.canPerform(withItems: [emailBody, zipFileURL]) {
// email can be sent
DispatchQueue.main.async {
emailService.perform(withItems: [emailBody, zipFileURL])
}
} else {
// email cannot be sent
// Show alert with email address and instructions
self.showErrorAlert(with: 2803)
}
This works correctly, but if the code is executed on a fresh system, Apple Mail will be opened asking the user to configure an email account. Some users may not understand what is going on in this situation. Is there a way to ascertain if the default Email Client is configured, so that I can inform the user if it is not ? Thanks for your help.
I'm trying to post to a Teams channel via the email address using SendGrid. However, the emails I send via SendGrid are not appearing. I ended up adding my personal email address as well, and I do receive that one as well as seeing the Teams email address in the To: field. I can also see in SendGrid dashboard that the email was send and delivered to the Teams channel address. I have validated that this address is correct, and have also posted via my non-work email address to that channel, so I know it's not because of a typo or an external email address. My guess is that there is something in the email meta data that is making Teams reject the email? Anyone have ideas 1) why Teams won't post the email coming from SendGrid and 2) how I might modify my request in SendGrid so that it works? Also, alternative suggestions on sending emails (for free) from nodejs are welcome.
Here is the code I'm using to send the email for reference:
var msg = {
to: ['TEAMSCHANNELID#amer.teams.ms','mycompanyemail#company.com'], // ChatBot Support Team, General Channel
from: 'noreply#chatbotapimonitor.com',
subject: `Service Interruption Notice: API ${test} is down (via ${functionName})`,
text: `API ${test} failed with error ${error}`,
html: `API ${test} failed with error ${error}`
};
try {
await sgMail.send(msg);
} catch (err) {
context.log(err);
}
It turns out that Teams won't accept incoming emails if the From address domain does not match the actual "sent from" domain. I recognized this by the "Sent via sendgrid.net" message I saw in Outlook when the emails were sent to me as well.
I was able to get the out of the box Incoming Webhooks enabled, and using that instead of SendGrid emails got around the problem. I got the URL from the webhook configuration and then was able to call it like so:
var headers = { 'ContentType': 'application/json'}
var body = {
'#context': 'https://schema.org/extensions',
'#type': 'MessageCard',
'themeColor': 'FF0000',
'title':`API ${test} is down: Service Interruption Notice`,
'text': `API ${test} failed with error ${error}.\n\r\n\rReported by ${functionName} during test started on ${now.toString()}`
};
var res = await request({
url: url,
method: 'POST',
headers: headers,
json: body,
rejectUnauthorized: false
});
The themeColor doesn't appear in all channels, but I have it working as a nice red/green indicator on Teams desktop.
Perhaps your organization limits the sending ability to only certain domains? Someone with admin rights can check it under Teams settings => Email integration
yeah that's what I meant - making your own Connector app and side-loading. If you go ahead with it, please let me know - would love to know how it works out
Yes exactly making your own Connector would work.
I am making a Contact us form page in my Flutter app and would like to send the details of the form (email of the user, name and the message) to my email address when the user hits the Send button. I don't want to launch the gmail app from phone for this. Are there any other ways to this?
Thanks!
Of course, you can.
You can use the flutter_email_sender package or flutter_mailer package. Both of them are very similiar.
For example if you are using flutter_email_sender package,
final Email myFormEmail = Email(
body: 'Email body', // This could be from the form field's value
subject: 'Email subject', // Subject (maybe type of question, etc)
recipients: ['example#example.com'], // This is receiver (maybe your email)
cc: ['cc#example.com'],
bcc: ['bcc#example.com'],
attachmentPaths: ['/path/to/attachment.zip'], // Attachments
isHTML: false,
);
And then inside the 'SEND' button, add this kind of code:
await FlutterEmailSender.send(myFormEmail);
Please check "mailer" package from flutter. It will use smtp to send email from background without opening userinterface app. It has gmail, yahoo mail, mailgun options to send email.
The Reference link :
https://pub.dartlang.org/packages/mailer
I wante to create a buton to be used when the suer wants to report a problem they can press it an will send them to their email app with my email already writen on it so they only need to write the email and I was wondering if that is a posibility on flutter.
Yes. Take a look at the url_launcher package. You can even set the subject and the body of the email.
Just search through the flutter packages. I personally have used flutter_email_sender which has a pretty full feature set, including subject, body and also attachments.
e.g.
final Email email = Email(
body: 'Email body',
subject: 'Email subject',
recipients: ['example#example.com'],
attachmentPaths: ['/path/to/attachment.zip'],
);
await FlutterEmailSender.send(email);
I am using the telepot python library, I know that you can send a message when you have someone's UserID(Which is a number).
I wanna know if it is possible to send a message to someone without having their UserID but only with their username(The one which starts with '#'), Also if there is a way to convert a username to a UserID.
Post one message from User to the Bot.
Open https://api.telegram.org/bot<Bot_token>/getUpdates page.
Find this message and navigate to the result->message->chat->id key.
Use this ID as the [chat_id] parameter to send personal messages to the User.
It is only possible to send messages to users whom have already used /start on your bot. When they start your bot, you can find update.message.from.user_id straight from the message they sent /start with, and you can find update.message.from.username using the same method.
In order to send a message to "#Username", you will need them to start your bot, and then store the username with the user_id. Then, you can input the username to find the correct user_id each time you want to send them a message.
You can't send message to users using their username that is in form of #username, you can just send messages to channel usernames which your bot is administrator of it. Telegram bot api uses chat_id identifier for sending messages. If you want to achieve chat_id of users, you can use telegram-cli, but it's not easy at all because that project is discontinued and you should debug it yourself.
in your case you should do following command:
> resolve_username vahid_mas
and the output will be something like this:
{
"user": {
"username": "Vahid_Mas",
"id": "$010000006459670b02c0c7fd66d44708",
"last_name": "",
"peer_type": "user",
"print_name": "Vahid",
"flags": 720897,
"peer_id": 191322468,
"first_name": "Vahid",
"phone": "xxxxxxx"
},
"online": false,
"event": "online-status",
"state": -1,
"when": "2017-01-22 17:43:16"
}
As the user you want to learn the ID of, send a message of any content to #JsonDumpBot. It will reply the whole JSON element that it receives from Telegram, including the ID of the user:
It's totally not safe to use other telegram versions available on internet, but I've seen that Telegram Plus has a ability to show you the chat_id of the user in their profile, even tho you don't have their contact.
Another way to extract chat_id of that particular user is that you have the phone number of that account, save it as your contact, then share it to this bot. It's easy to code it yourself but you can forward something from that user to this bot too, if you want to recieve the chat_id.
urmurmur has also mentioned another way. I haven't checked it yet but seems to be interesting.
Maybe you can try telethon:
from telethon import TelegramClient
def send_msg(name, msg):
with TelegramClient(session_file, app_id, app_hash, proxy=my_proxy) as client:
# client.loop.run_until_complete(client.send_message('me', 'hello')) # send 'hello' to saved messages
client.loop.run_until_complete(client.send_message(name, msg))
"name" can be "#xxxxx".
Then you can call send_msg(name, msg) in your bot.