For the past few days I've been strugling with finding a way to send emails from my app. This is the sample code I am currently using. It think, by using this method, I might be unable to handle the situation of an improper setting of the mail accound of the computer my app will be running, so I thought about using a different method. I was wondering if is there any MessageUI equivalent for mac os. Is there any MessageUI equivalent for mac os. Any ideas?
There are two ways to do that:
AppleScript framework
NSSharingService
NSSharingService to compose mail:
let service = NSSharingService(named: NSSharingServiceNameComposeEmail)
service?.recipients = ["test#gmail.com"]
service?.subject = "Test Mail"
service?.performWithItems(["Test Mail body"])
Launch Mail App
If you just want to open Mail app, try below code:
NSWorkspace.sharedWorkspace().launchApplication("Mail")
Improper Setting:
If account is not configured on the system, this code will show configuration window for mail
When user will try to send mail it'll be shown improper setting related error by Mail app so you need not to bother about it
If you want to use other then Mail app, just try your own mail system, native mail client or third party mail framework.
Try from terminal:
You can use shell script to send mail using native client
mail -s "Hello" "test#gmail.com" <<EOF
Hello, Test!
EOF
For Swift 4, little changes.
let service = NSSharingService(named: NSSharingService.Name.composeEmail)
service?.recipients = ["test#gmail.com"]
service?.subject = "Test Mail"
service?.perform(withItems: ["Test Mail body"])
Related
I have set up a motion detection camera on my raspberry pi zero w, and it's able to record videos and save pictures and upload them to dropbox but not sending email notifications on_event_start and this is how I defined my on_event_start (on_event_start echo "email body" | mail -s "subject" myEmail#gmail.com). I'm using ssmtp and mailutils for email packages. Although I'm able to send emails through terminal. This is how my ssmtp.conf looks like:
root=postmaster
mailhub=smtp.gmail.com:587
hostname=raspberrypi
AuthUser=myEmail#gmail.com
AuthPass=***********
FromLineOverride=YES
UseSTARTTLS=YES
UseTLS=YES
RewriteDomain=gmail.com
And this is how my revaliases looks like:
root:myEmail#gmail:mail.google.com:587
This is the error that is logged onto the mail.log when motion is detected by the camera.
Unable to connect to "mail.google.com" port 587.
Cannot open mail.google.com:587
Is there something that i'm missing or is there any other way to send an email notification when motion is detected? Someone please help me on this.
Your revaliases file should be pointing to smtp.gmail.com instead of mail.gmail.com. Please try with following in your revaliases file:
root:MyEmailAddress#gmail.com:smtp.gmail.com:587
I am trying to figure out EXM for Sitecore. I installed it and now I am trying to configure it to send emails from my local machine. SAC MTA is not an option because I don't have access to App Center. I am left with custom MTA.
I was trying to configure config files to use gmail smtp:
Sitecore.EDS.Providers.CustomSmtp.config
<smtpSettings type="Sitecore.EDS.Core.Net.Smtp.SmtpSettings, Sitecore.EDS.Core" singleInstance="true">
<server>smtp.gmail.com</server>
<port>465</port>
<userName>*****#gmail.com</userName>
<password>*****</password>
<authenticationMethod>Login</authenticationMethod>
<startTls>true</startTls>
<proxySettings ref="exm/eds/proxySettings" />
</smtpSettings>
Sitecore.EDS.Providers.CustomSmtp.Sync.config
<pop3Settings>
<pop3Setting type="Sitecore.EDS.Core.Net.Pop3.Pop3Settings, Sitecore.EDS.Core" singleInstance="true">
<server>pop.gmail.com</server>
<port>995</port>
<userName>****#gmail.com</userName>
<password>****</password>
<useSsl>true</useSsl>
<startTls>true</startTls>
<proxySettings ref="exm/eds/proxySettings"/>
</pop3Setting>
</pop3Settings>
But when I try to "send quick test" through EXM I get "Failed to connect to the email server. Please try again later". Can anyone help me with that configuration. And is it even possible? I remember reading something about paid license to use custom MTA. Would it mean, that you need to pay to send email via EXM?
To switch from using the Sitecore MTA to using the Custom SMTP, you must disable the Dyn configurations and then enable the CustomSmtp configurations:
In the Website\App_Config\Include\EmailExperience folder, add the suffix .disabled to the end of the following file names:
Sitecore.EDS.Providers.Dyn.config
Sitecore.EDS.Providers.Dyn.Sync.config
In the Website\App_Config\Include\EmailExperience folder, remove the suffix .disabled from the following file names:
Sitecore.EDS.Providers.CustomSmtp.config.disabled
Sitecore.EDS.Providers.CustomSmtp.Sync.config.disabled
I have set up a Gerrit server and trying to make it send emails (for all events). But for some reason Gerrit doesn't send any emails. error_logs shows absolutely no data, that means it is not even trying to send emails.
Here is relevant part of my project.config for All-Projects:
[notify "demo"]
email = me#company.com
type = all
Here is my gerrit.config:
[gerrit]
basePath = git
canonicalWebUrl = http://hostname:8443/
[database]
type = h2
database = db/ReviewDB
connectionPool = true
poolLimit = 128
[index]
type = LUCENE
[auth]
type = LDAP
[ldap]
poolDebug = all
server = ldap://nod.company.com
accountBase = cn=users,dc=company,dc=com
accountEmailAddress = mail
referral = follow
[sendemail]
smtpServer = relay.company.com
smtpServerPort = 25
smtpUser = my_username
[container]
user = gerrit2
javaHome = /usr/lib/jvm/java-7-openjdk-amd64/jre
heapLimit = 2g
[sshd]
listenAddress = *:29419
maxConnectionPerUser = 256
[automerge]
botEmail = me#company.com
[download]
scheme = ssh
[httpd]
listenUrl = http://*:8443/
maxThreads = 128
[cache]
directory = cache
[gitweb]
cgi = /usr/share/gitweb/gitweb.cgi
Environment: Ubuntu 14.04 and Gerrit 2.11.6.
I have tried to send emails from command line on this server and that works just fine.
All of my individual projects on Gerrit inherit access rights from All-Projects. I even tried adding the email section to each individual project but that didn't help either.
My colleague, who has his own Gerrit server that is able to send emails, looked into my issue and couldn't figure out what's wrong with my server. We both have same Linux version, Gerrit version, gerrit.config and project.config.
Ok, found the issues and fixed them. I had two issues, sharing for user reference.
I installed sendmail utility when logged in as a user other than smtpUser account mentioned in gerrit.config. After that I forgot to add the sendmail utility to /opt and hence the smtpUser's account from gerrit.config was not able to access the sendmail utility. Once I shared the sendmail utility with all user accounts, gerrit started sending emails.
To summarize, make sure the user account mentioned under smtpUser has sendmail available to it. Thanks everyone for your time.
gerrit wont send the email ONLY to the user that is also the smtpUser in gerrit.config. I was testing it by sending emails to only me, and hence it didnt work. I had to change to project config to add an email address other than my own email account.
I dont know if this is a gerrit bug or a gerrit feature. If a feature then not sure what is the use case for this !!
I hope this info helps other guys out there.
I had this problem after a recent Gerrit update (from 2.15 -> 3.2).
I checked the postfix logs in /var/log/maillog and they clearly showed that after the machine was rebooted following the Gerrit update no more mails arrived here.
Looking further into <gerrit-path>/logs/error_log (I had to look in rollated files) showed me that there seemed to be a problem with our mail template and also gave me the path to the offending file.
We previously used a custom mail template from https://gist.github.com/orgads/d8a61a1c10efeb7a4fafbcb6374167c3, the format of which seems to no longer be valid. I replaced this with the .soy.example file provided by Gerrit which fixed the issue.
For me, since I was trying to test emails by getting them to send to my own email, I had to go to settings (Gerrit 2.15.17 BTW), then preferences, under email notifications, select "every comment" in the dropdown menu.
i am currently developing a website which requires email verification, but i am developing on windows, and would like to test sending email verifications on localhost. I tried using Test Mail Server Tool, but i don't think i am setting it up correctly because there were no errors, but i didn't receive any email. this is the code i put in my config file
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['mailpath'] = 'C:\Program Files\Toolheap\Test Mail Server Tool\TestMailServerTool.exe';
$config['protocol']= 'smtp';
what am i doing wrong? i am really new to this so i have no idea where to start looking.
i created an email.php and put that in application/config/ so i don't think i need to initialize it?
thanks in advance.
Have you checked whether or not you need to include the following configuration options?
smtp_host
smtp_user
smtp_pass
smtp_port
I am signed up for AWS SES (with instance, S3 and my website running nicely). I also have rec'd approval for sending out email without receiver verification and "mass production" OK. The only thing I'm left with is having my 3 "from" email addresses verified. Started to download Perl, as was suggested to run email-verification scripts -- but got no where with the installation. Do have my credentials ready to use.
There is an AWS SES API to use for verification which I can't find... suspect that it has something to do with AWS's sdk which I could figure out how to install.
So my question: is there a simple, straight forward way to get my email addresses to Amazon for verification via a response email they send? Their documentation is somewhat confusing.
You have to go validate your email address through their web service (like the perl script is doing). You can also use their SDK's that they publish, which are wrappers around their web service. For example, if you have Visual Studio, you can use the AWS SDK for .NET (also available as a Nuget package: PM> Install-Package AWSSDKForNET) and set up a simple console application to do something like this:
using Amazon.SimpleEmail;
using Amazon.SimpleEmail.Model;
static class Program {
static void Main() {
var client = new AmazonSimpleEmailServiceClient("yourAccessKey", "yourSecretKey");
var request = new VerifyEmailAddressRequest { EmailAddress = "yourEmailAddress" };
client.VerifyEmailAddress(request);
}
}
They also have SDK's available in PHP and Java that work pretty much the same.
This is an old post but came up in a search.
You can now verify emails directly from the SES control panel (See screen shot)
AWS SES Panel