datawookie / emayili Goto Github PK
View Code? Open in Web Editor NEWAn R package for sending email messages.
Home Page: https://datawookie.github.io/emayili/
An R package for sending email messages.
Home Page: https://datawookie.github.io/emayili/
Thanks for creating the package - nice solution!
When I try to include a "name" along with the email address I'm seeing an error come back from AWS SES. I've tried various syntax variations. Is it a new feature request for emayili or do you have a syntax suggestion?
email <- envelope() %>%
from("My Name <[email protected]>") %>%
to(email_to) %>%
cc(email_cc) %>%
subject("Subject") %>%
text("Body of email.") %>%
attachment(log_file) %>%
attachment("error.log")
smtp <- server(host = email_endpoint,
port = email_wrapper_port,
username = email_username,
password = email_pwd,
insecure = FALSE,
reuse = FALSE)
smtp(email, verbose = TRUE)
[edited content for possible sensitive information - see last couple of lines]
Sending email to smtps://.
Hostname in DNS cache was stale, zapped
Trying
TCP_NODELAY set
Connected to
220 ESMTP SimpleEmailService-
EHLO Machine-Name
250-
250-8BITMIME
250-AUTH PLAIN LOGIN
250 Ok
AUTH PLAIN
334 Ok
235 Authentication successful.
MAIL FROM:<My Name [email protected]>
553 <My Name [email protected] Invalid email address.
MAIL failed: 553
QUIT
I followed instructions and have had no problems executing from RStudio and running the script using Rscript from the bash command line (mac os X). But when I run it from crontab I get the connection errors you see below.
Isaac Kohane
Sending email to smtps://p3plcpnl0846.prod.phx3.secureserver.net:465/ .
Trying 50.62.177.159...
TCP_NODELAY set
Immediate connect fail for 50.62.177.159: Host is down
Closing connection 0
Error in curl_fetch_memory(smtp_server, handle = h) :
Couldn't connect to server
Calls: smtp -> send_mail -> curl_fetch_memory
Execution halted
Can you, please, export message()
? It does look like a method of class envelope()
(something like as.character.envelope()
). I am currently using it with :::
, which is not very nice :)
Hey Andrew,
You've been busy :-) Nice to see this package on CRAN.
I'd been using a local fork since late November, and just pulled in all your changes today. Aside from some breaking changes to attachment()
and body()
, things looked good.
But, additional testing revealed the following issues:
Some experimentation traced the culprit to this commit, changing the Content-type on the outermost container from multipart/mixed
to multipart/related
. No explanation was given for the change.
Changing back to multipart/mixed
resolved the issues, and restored prior functionality.
In case it's relevant, here's the pattern I'm using to construct emails:
mailResults <- function(recipients, subject, attachFilenames) {
email <- envelope() %>%
from("[email protected]") %>%
to(recipients) %>%
subject(sprintf("%s, %s", subject, lubridate::date(now()))) %>%
html(subject)
for (i in seq_along(attachFilenames)) {
email <- email %>%
attachment(attachFilenames[i])
}
.
.
.
I'm certainly no expert on MIME stuff, but the bit of digging I did (here, here, here), seems to indicate that when using multipart/related
additional ordering information is needed for the parts/attachments.
Hi,
Thanks for this package.
I've tried to send an email using the example code and body text arrived as attachment.
https://www.dropbox.com/s/svvifqt2gbq53se/Screenshot%202019-10-06%2013.02.27.png?dl=0
https://www.dropbox.com/s/ffg2c3mfp3x6qco/Screenshot%202019-10-06%2013.02.36.png?dl=0
Hey, thanks for the nice package! Nice to have an option working without java
Could you allow sending mails without the need to set a cc address? Setting cc
to NULL
does not send the mail, so only option working for me is specifying to
and cc
with the same parameter, which results in two incoming mails
Best regards
Thomas
Is it possible to send an email with a HTML body using an existing HTML file created by rmarkdown?
Thanks a lot.
I'm trying to send an email on a Windows 10 machine in an enterprise context, but I get an error about an invalid token.
library(curl)
library(emayili)
library(magrittr)
email <- envelope()
class(email)
#> [1] "envelope"
email <- email %>%
from("myemail") %>%
to("myemail") %>%
subject("This is a test") %>%
text("This is text")
smtp <- server(host = "mail.domain.com",
port = 465,
username = "user",
password = "pwd")
smtp(email, verbose = TRUE)
#> Error in curl_fetch_memory(url, handle = h): schannel: next InitializeSecurityContext failed: SEC_E_INVALID_TOKEN (0x80090308) - The token supplied to the function is invalid
Created on 2020-03-13 by the reprex package (v0.3.0)
Hi, thanks for the excellent package. It's really great not having to worry about JAVA dependencies. I am trying to send an email with an inline image in an html body but image keeps turning blank. If I attach the same image then I get it fine as an attachment (but not in the body of the email). Am I doing something wrong?
library(emayili)
library(dplyr)
html <- '<html><body style="font-family:calibri;">
<p><i>Email text</i></p>
<img src="C:/Users/xxxx/Documents/branding.png"></body></html>
'
email <- envelope()
email <- email %>%
from("<[email protected]>") %>%
to("[email protected]") %>%
subject("This is an html message!") %>%
html(html) %>%
attachment(path = "C:/Users/xxxx/Documents/branding.png")
smtp <- server(host = "xxxxxxx",
port = 25,
insecure = FALSE,
reuse = FALSE)
smtp(email, verbose = TRUE)
I am trying to send emails with Qualtrics preformatted links for a group of participants. Everything works, except that the links are changed when the email is sent.
In this example, the link
"https://website.com/XY_stuff?Q_DL=2a94hds4QmHP_9NaQ3odv_MLRP_9GNlEdOXL2q9&Q_CHL=gl"
becomes
"https://website.com/XY_stuff?Q_DL*94hds4QmHP_9NaQ3odv_MLRP_9GNlEdOXL2q9&Q_CHL="
There are two unwanted changes in this case:
Here is a minimal working example [minus emails and password]:
library(emayili)
library(dplyr)
LINK = "https://website.com/XY_stuff?Q_DL=2a94hds4QmHP_9NaQ3odv_MLRP_9GNlEdOXL2q9&Q_CHL=gl"
FROM = "FROM_EMAIL_HERE"
TO = "TO_EMAIL_HERE"
email <- envelope() %>%
from(FROM) %>%
to(TO) %>%
subject("test") %>%
emayili::body(
paste0(
"LINK: ", LINK),
type = "html")
smtp <- server(host = "smtp.office365.com",
port = 587,
username = FROM,
password = THE_PASSWORD_HERE)
smtp(email, verbose = TRUE)
Thanks for the great package!
Can you add a sender function, in the same style as from, so that it can be attached to the header? This would allow those of us who are sending from inside an organization the option to state that the email is being sent on behalf of the user by another machine.
Hello and thanks for this wonderful user-friendly package!
I may have spotted a couple of issues:
When sending mail to MS Exchange servers, it bounces back (or ends in spam in the best case) because the mail headers (constructed essentially in format.mime()
and elsewhere) are separated by \n
(or <LF>
) instead of \r\n
(or <CR><LF>
) as it seems that this is the standard SMTP protocol. More information can be found here.
Some accidental argument order inconsistencies in body.R
(namely in the text()
and html()
functions caused problems with UTF-8 encoding and possibly attachments. The arguments passed to mime()
were in a different order than expected by mime()
.
I forked the package here and fixed (I believe) the above two issues. If you are happy I can make a PR.
Thanks again for all the work.
For my use case, I would like to verify to the smpt server not with a username and password, but only with a client certificate. I wanted to ask if this is supported somehow or if there is as workaround?
I've tried sending some emails but my Email signature (put in gmail for this one) is not included inline.
Do I need to manually add it or is there a way to automatically include it?
envelope()%>%
from(sender)%>%
to(reciever)%>%
subject(subject_line)%>%
html(content=html_text)
Hi,
I am using actively the package for a couple of months.
Today was changing some code by accident typed my personal email in from
instead of the email in stmp
.
My biggest suprise was that the email was sent through and I received an email to my inbox.
Next I tried typing some random emails, and it worked again. Finally I typed this
email <- email %>%
from("helloworld") %>%
to(mymail)
And this is what I have in my inbox
So sender is basically helloworld
, not a real email, doesn't say it was forwarded from the server or anything.
Is this something to do with the package? Should I correct the settings?
Hi, I created a list of birthdays, to automatically wish the person who has the birthday that day and also to remind others that it's this person's birthday by creating 2 smtp. Also instead of sending mass email all at once, I used for loop to send it individually. The code looks like this
# special email to the particular person
email <- emayili::envelope() %>%
from(from) %>%
to(to) %>%
subject("") %>%
emayili::text(special_text)
smtp <- server(host = "smtp.gmail.com",
port = 465,
username = username,
password = password)
smtp(email, verbose = TRUE)
Sys.sleep(11)
#email reminder to others
to <- cellphone %>%
filter(last_name != !!last_name) %>%
pull(cell)
for (i in to) {
email <- emayili::envelope() %>%
from(from) %>%
to(i) %>%
subject("") %>%
emayili::text(other_text)
smtp <- server(host = "smtp.gmail.com",
port = 465,
username = username,
password = password)
smtp(email, verbose = TRUE)
Sys.sleep(11)
}
It was only able to send the first email to the special person, not the rest. But when I tried it on smtpbucket, it worked. Thanks!
If my email has a pdf attachment, and I add text to the body of the email using text(), the attachment is not accessible/visible on a device running iOS (or iPadOS). The general issue with smtp and iOS is document in this Stack Overflow post.
Wonderful package that does not need Java! I got it running locally.
I also tried to install this on the server. Installing from Github did not succeed, so I created emayili_0.2.2_R_x86_64-pc-linux-gnu.tar.gz and tried to install with: install.packages("emayili_0.2.2_R_x86_64-pc-linux-gnu.tar.gz", repos = NULL, type = "source").
But this gave an error: '‘cannot read workspace version 3 written by R 3.6.2; need R 3.5.0 or newer’'.
I cannot change the R version on the server. Is er there nevertheless any trick to solve this?
I have an 'unknown' issue when i try to send a smtp mail from a dockerized app.
Rebuilt URL to: smtp://smtp.gmail.com:587/
Trying 64.233.165.108...
TCP_NODELAY set
Connected to smtp.gmail.com (64.233.165.108) port 587 (#0)
< 220 smtp.gmail.com ESMTP y25sm8936760lfy.59 - gsmtp
EHLO f3343a22938f
250-smtp.gmail.com at your service, [92.53.46.200]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
STARTTLS
220 2.0.0 Ready to start TLS
Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@strength
successfully set certificate verify locations:
CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
Server certificate:
subject: C=US; ST=California; L=Mountain View; O=Google LLC; CN=smtp.gmail.com
start date: Dec 3 14:47:42 2019 GMT
expire date: Feb 25 14:47:42 2020 GMT
subjectAltName: host "smtp.gmail.com" matched cert's "smtp.gmail.com"
issuer: C=US; O=Google Trust Services; CN=GTS CA 1O1
SSL certificate verify ok.
EHLO f3343a22938f
250-smtp.gmail.com at your service, [92.53.46.200]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
AUTH LOGIN
< 334 VXNlcm5hbWU6
ZG9ja2VydGVzdDM3QGdtYWlsLmNvbQ==
334 UGFzc3dvcmQ6
ZVY1UDhiaUomNSQ0
235 2.7.0 Accepted
MAIL FROM:[email protected]
250 2.1.0 OK y25sm8936760lfy.59 - gsmtp
*** caught segfault ***
address (nil), cause 'unknown'
Traceback:
1: curl_fetch_memory("smtp://smtp.gmail.com:587", handle = h)
2: email.project.zip(user.email = user.list)
3: eval(ei, envir)
4: eval(ei, envir)
....
38: r$run(port = 80, host = "0.0.0.0")
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault
Hi,
it seems that the version of curl available on cran (4.2) is sufficient. No need to install the development version anymore.
Best
Hi There
I would like my attachment input from this package to allow for a variable input also unfortunately it only accepts a path of the attachment file.
I used a paste() as the attachment input function but it comes up with an error stating the file can't be found.
This will occur naturally as you are changing a path input to text
Here is a snapshot of what I am trying to do:
myname <-"Natasha"
email <- envelope() %>%
from("[email protected]") %>%
to("[email protected]") %>%
subject(paste("My name is :", myname)) %>%
attachment(paste("~/test_report.html","- " ,myname), disposition = "attachment")
smtp(email, verbose = TRUE)
I will email directly with code that works!
Thanks,
Natasha
In version 0.4.16, the From field is modified to a list and this leads to a Sender Identity error.
In version 0.4.15 I had:
To: [email protected]
From: [email protected]
Cc: [email protected], [email protected]
Subject: Test
X-Mailer: {emayili}-0.4.15
MIME-Version: 1.0
Content-type: multipart/mixed; boundary="****************"
Now I have (the From field is different):
To: [email protected]
From: list(email = "[email protected]", display = NA)
Cc: [email protected], [email protected]
Subject: Test
X-Mailer: {emayili}-0.4.16
MIME-Version: 1.0
Content-type: multipart/mixed; boundary="****************"
Which eventually leads to this error:
The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements
> GMF$Util$RMD2HTML
function (sourceFilePath, outputFilePath = NULL, environment = NULL)
{
markdown <- ReadFile(sourceFilePath)
html <- MD2HTML(markdown, workingDirectory = sourceFilePath,
environment)
html <- sub("^<!DOCTYPE html>\n", "", html)
if (!is.null(outputFilePath)) {
WriteFile(text = html, fileName = outputFilePath)
}
return(html)
}
> MD2HTML
function (markdown, workingDirectory = NULL, environment = NULL)
{
SetKnitrOptions(workingDirectory)
if (is.null(environment))
environment <- parent.frame()
html <- knitr::knit2html(text = markdown, options = c("use_xhtml",
"smartypants", "mathjax", "highlight_code"), stylesheet = GetMarkDownCss(),
envir = environment)
return(html)
}
Hi Andrew
I have moved hosting to AWS and are running R on an Ubuntu server there.
It seems Amazon is very strict on sending emails from their servers, so just using google smtp doesnt work.
Ive followed all the steps to setup their SES, Simple Email Serves, to use their own smtp server, but when running the emayili script it just stops at a certain point and then crashes. I have attached the output below?
I assume its a AWS setup issue, but does this output mean anything to you?
Thanks
Regards
Jan
smtp <- server(host = "email-smtp.us-east-1.amazonaws.com",
port = 465,
username = “amazon_smtp_un",
password = "amazon_smtp_pw")
email <- envelope() %>%
from("[email protected]") %>%
to('[email protected]') %>%
subject("Good morning report") %>%
body('Hi')
smtp(email, verbose = TRUE)
Sending email to smtps://email-smtp.us-east-1.amazonaws.com:465.
EHLO ip-172-31-3-23
< 250-email-smtp.amazonaws.com
< 250-8BITMIME
< 250-SIZE 10485760
< 250-AUTH PLAIN LOGIN
< 250 Ok
AUTH LOGIN
< 334 VXNlcm5hbWU6
QUtJQTVYNkZGRUs0SUEyNFdYV1c=
< 334 UGFzc3dvcmQ6
Qkd6bCtNTFVUaXErWXNjbEZiQlErYW1La09pV2gvM2lyemR6bmgwY1FWTXo=
My script sending emails with Emayili was working fine and suddenly it stopped working. Here is the error log:
Sending email to smtps://smtp.gmail.com:465/.
Found bundle for host smtp.gmail.com: 0x24b7a0ba4a0 [serially]
Re-using existing connection! (#1) with host smtp.gmail.com
Connected to smtp.gmail.com (2800:3f0:4003:c00::6d) port 465 (#1)
MAIL FROM:[email protected]
421 4.7.0 Try again later, closing connection. (MAIL) g4sm240722pgs.42 - gsmtp
MAIL failed: 421
QUIT
schannel: server closed abruptly (missing close_notify)
Closing connection 1
schannel: shutting down SSL/TLS connection with smtp.gmail.com port 465
Trying 2800:3f0:4003:c02::6d...
TCP_NODELAY set
Connected to smtp.gmail.com (2800:3f0:4003:c02::6d) port 465 (#2)
220 smtp.gmail.com ESMTP g19sm112160pjl.25 - gsmtp
EHLO DESKTOP-VE1RNE6
250-smtp.gmail.com at your service, [2804:18:581a:910f:31ae:b3fd:4149:9b7c]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
AUTH PLAIN
334
bmVvdHJvcGljYWwubmV0d29ya3NAZ21haWwuY29tAG5lb3Ryb3BpY2FsLm5ldHdvcmtzQGdtYWlsLmNvbQB2YWlkYXJjZXJ0bzIwMjE=
235 2.7.0 Accepted
MAIL FROM:[email protected]
421 4.7.0 Try again later, closing connection. (MAIL) g19sm112160pjl.25 - gsmtp
MAIL failed: 421
QUIT
schannel: server closed abruptly (missing close_notify)
Closing connection 2
<error/purrr_error_rate_excess>
Request failed after 5 attempts
Backtrace:
x
\-purrr::rate_sleep(rate, quiet = quiet)
\-purrr:::stop_rate_excess(rate)
@kleinbub and @EricGoldsmith I thought I'd create a separate thread for this.
@EricGoldsmith raises a good point here. For maximum flexibility it would be useful to be able to specify Content-Disposition
for each attachment.
There are (at least) two options:
attachment()
allows for multiple attachments orattachment()
only accepts a single attachment.The first option is what we have currently implemented in the cid
branch. An (optional) vector of CIDs can be specified, which must match the vector of attachments. We could also accept a similar vector giving the Content-Disposition
for each attachment.
The second option is probably cleaner. We can expose parameters for giving a CID and also Content-Disposition
. Would not have to worry about whether there are enough values in each of these.
I'm thinking of an interface like this:
email %>% attachment("image.png", cid = "img", disposition = "inline")
The defaults for both cid
and disposition
would be NULL
, in which case the function would figure out to do "the right thing".
I know that this would be a breaking change. However, since this package is still in its infancy, now is the time to make these sorts of design decisions.
What do you think? Despite the great work that @kleinbub has done on handling multiple attachments in a single call, I personally prefer the second option.
Hi Andrew,
I saw #45 and logged in successfully by manually typing in info. Does this package work for Office 365 Business?
smtp <- server(host = "smtp.office365.com",
port = 587,
username = "",
password = "")
Thanks,
Gabriella
I am working with the new version of R (3.6.2) and I can't install the library.
Is there a way, that emayili runs on that version?
Sometimes you have all the parts of an email ready to go, and you just want to construct the whole thing at once rather piping to calls of from()
, to()
, subject()
, etc. It would be nice if envelope()
could optionally accept these parts and construct in one go, something like:
envelope(
from = "[email protected]",
to = c("[email protected]", "[email protected]"),
subject = "an email",
text = "stuff",
...
)
where any of those arguments could be omitted and later added with the appropriate function call. This would allow users to use do.call()
or pmap
to construct emails.
I use this code for sending an email using curl
.
library(emayili)
library(curl)
library(magrittr)
message <- 'From: "Jelle Geertsma" <[email protected]>
To: "Jelle Geertsma" <[email protected]>
Subject: Hello there!
Hoi Jelle,
Eerste email!'
recipients <- c('[email protected]')
sender <- '[email protected]'
username <- '[email protected]'
password <- "mypassword"
send_mail(mail_from=sender, mail_rcpt=recipients, smtp_server = 'smtp://mail.ouremailserver.nl',
message = message, username = username, password = password)
This is the message I get:
* Found bundle for host smtp: 0x6a9f4e0 [serially]
* Re-using existing connection! (#9) with host smtp
* Connected to smtp (93.95.2.215) port 25 (#9)
> MAIL FROM:<[email protected]>
< 250 2.1.0 Ok
> RCPT TO:<[email protected]>
< 250 2.1.5 Ok
> DATA
< 354 End data with <CR><LF>.<CR><LF>
Uploaded 140 bytes... all done!
< 250 2.0.0 Ok: queued as 092C5857CEF
* Connection #9 to host smtp left intact
This email is sent perfectly.
When I use this code:
email <- envelope()
email <- email %>%
from("[email protected]") %>%
to("[email protected]") %>%
cc("[email protected]")
email <- email %>% subject("This is a plain text message!")
email <- email %>% body("Hello!")
images <- paste0(list.files(pattern = "\\.png$"))
email <- email %>% attachment(images[1])
smtp <- server(host = "mail.ouremailserver.nl",
port = 587,
username = "[email protected]",
password = "mypassword")
smtp(email, verbose = TRUE)
This is the error I get:
Sending email to smtp://mail.happyatwork.nl:587.
* Connection 3 seems to be dead!
* Closing connection 3
* Trying 93.95.0.156...
* TCP_NODELAY set
* Connection timed out after 10007 milliseconds
* Closing connection 5
Error in curl_fetch_memory(url, handle = h) :
Timeout was reached: Connection timed out after 10007 milliseconds
I also tried port 25 (as send_mail
seemed to use that one), but that one failed as well. Any ideas about what causes this problem? Thank you very much in advance!
Hi
I tried to use the package with an email account with the domain name "exegetic.biz". When I try to use this domain to send an email I get the error:
I also had a warning email from Google in my mailbox: "Someone just used your password to try to sign in to your account from a non-Google app. Google blocked them, but you should check what happened. Review your account activity to make sure no one else has access."
Hi there,
Just wondering if I want to send a blast to a list of emails. Will successfully sent emails be viewable in my sent folder (I'm using bluehost for context).
I'm wondering because I did send several emails but none of them are in my sent folder. However whenever I send it to myself (as a test)- its seen in my sent folder.
Would that be a good hueristic?
Thanks!
Would it be possible to include a quick example of how these functions are used in the creation of a multi part mime document. I've been playing, but there's no examples, and have had no luck so far.
thanks, andrew
This is such a small change, doesn't seem worth a PR, so documenting here.
Modify this code:
curl_fetch_memory(url, handle = h)
close(con)
}
to this:
res <- curl_fetch_memory(url, handle = h)
close(con)
invisible(res)
}
In order to return status info to the caller.
Hi,
I got an error when sending an email with emayili. Any idea why is the error?
email <- envelope() %>%
from("[email protected]") %>%
to("[email protected]") %>%
subject("This is a plain text message!") %>%
text("Hello!")
smtp <- server(host = "smtp.gmail.com",
port = 465,
username = "[email protected]",
password = "xxxxxxxxx")
smtp(email, verbose = TRUE)
Error in curl_fetch_memory(url, handle = h) : Login denied
Manuel
I recently started using emayili as a non-java-dependent alternative to mailR, and I really like it for local use. I use it in a Shiny app to send emails with attachments, and when I run it locally, it works flawlessly. However, as soon as I run it on a server, I get curl-related errors (please let me know if this would be more appropriate on a curl-associated thread) that I think are related to my smtp() call.
My shiny server code looks like this:
server <- function(input, output) {
observeEvent(input$submitdata, {
isolate({
email = envelope() %>%
from("[email protected]") %>% # changed for privacy
to("[email protected]") %>% # changed for privacy
subject(paste("New data submitted from", input$name, sep = " ")) %>%
text(paste(input$name, "from institution:", input$inst, "with email:", input$email,
"has submitted data.",
"This data is attached to this email",
input$name, "sent the following note accompanying this data:", input$note, collapse = ","))
smtp = emayili::server(host = "smtp.gmail.com" # need to make sure it knows it's the emayili::server function, not the shiny::server function
, port = 465
, username = "username" # changed for privacy
, password = "password" # changed for privacy
)
email = email %>%
attachment(input$userdata$datapath
, name = paste(timeDate(Sys.time(), FinCenter = "America/Denver"), input$name, "user_data", ".csv", sep = "_", collapse = ","))
smtp(email, verbose = T)
})
})
}
When I run this in a local shiny app (the UI is just some text input fields, a file upload button to attach the attachment, and then a send button), it functions just fine and sends the email and attachment successfully.
When I deploy the app, I can attach a file and click send, and the app crashes, giving me the following log, with the error "Error in curl_fetch_memory: Login denied".
2020-08-24T18:29:47.434053+00:00 shinyapps[255593]: Sending email to smtps://smtp.gmail.com:465/ .
2020-08-24T18:29:47.440019+00:00 shinyapps[255593]: Trying 173.194.207.109...
2020-08-24T18:29:47.451947+00:00 shinyapps[255593]: Connected to smtp.gmail.com (173.194.207.109) port 465 (#0)
2020-08-24T18:29:47.452280+00:00 shinyapps[255593]: ALPN, offering http/1.1
2020-08-24T18:29:47.452335+00:00 shinyapps[255593]: Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
2020-08-24T18:29:47.457417+00:00 shinyapps[255593]: CAfile: /etc/ssl/certs/ca-certificates.crt
2020-08-24T18:29:47.457410+00:00 shinyapps[255593]: successfully set certificate verify locations:
2020-08-24T18:29:47.457417+00:00 shinyapps[255593]: CApath: /etc/ssl/certs
2020-08-24T18:29:47.457498+00:00 shinyapps[255593]: TLSv1.2 (OUT), TLS header, Certificate Status (22):
2020-08-24T18:29:47.457526+00:00 shinyapps[255593]: ����TLSv1.2 (OUT), TLS handshake, Client hello (1):
2020-08-24T18:29:47.467007+00:00 shinyapps[255593]: ����TLSv1.2 (IN), TLS handshake, Server hello (2):
2020-08-24T18:29:47.467055+00:00 shinyapps[255593]: ���� 'TLSv1.2 (IN), TLS handshake, Certificate (11):
2020-08-24T18:29:47.467390+00:00 shinyapps[255593]: ����TLSv1.2 (IN), TLS handshake, Server key exchange (12):
2020-08-24T18:29:47.467564+00:00 shinyapps[255593]: ���TLSv1.2 (IN), TLS handshake, Server finished (14):
2020-08-24T18:29:47.467708+00:00 shinyapps[255593]: ����TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
2020-08-24T18:29:47.467749+00:00 shinyapps[255593]: ����TLSv1.2 (OUT), TLS change cipher, Client hello (1):
2020-08-24T18:29:47.467822+00:00 shinyapps[255593]: ����TLSv1.2 (OUT), TLS handshake, Finished (20):
2020-08-24T18:29:47.476654+00:00 shinyapps[255593]: ����TLSv1.2 (IN), TLS change cipher, Client hello (1):
2020-08-24T18:29:47.476723+00:00 shinyapps[255593]: ����TLSv1.2 (IN), TLS handshake, Finished (20):
2020-08-24T18:29:47.476736+00:00 shinyapps[255593]: �SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-GCM-SHA256
2020-08-24T18:29:47.476776+00:00 shinyapps[255593]: subject: C=US; ST=California; L=Mountain View; O=Google LLC; CN=smtp.gmail.com
2020-08-24T18:29:47.476739+00:00 shinyapps[255593]: ALPN, server did not agree to a protocol
2020-08-24T18:29:47.476755+00:00 shinyapps[255593]: Server certificate:
2020-08-24T18:29:47.476792+00:00 shinyapps[255593]: start date: Aug 11 08:57:38 2020 GMT
2020-08-24T18:29:47.476838+00:00 shinyapps[255593]: issuer: C=US; O=Google Trust Services; CN=GTS CA 1O1
2020-08-24T18:29:47.476864+00:00 shinyapps[255593]: SSL certificate verify ok.
2020-08-24T18:29:47.476811+00:00 shinyapps[255593]: expire date: Nov 3 08:57:38 2020 GMT
2020-08-24T18:29:47.476832+00:00 shinyapps[255593]: subjectAltName: smtp.gmail.com matched
2020-08-24T18:29:47.499016+00:00 shinyapps[255593]: ���220 smtp.gmail.com ESMTP a135sm4481992qkg.71 - gsmtp
2020-08-24T18:29:47.499051+00:00 shinyapps[255593]: ���EHLO 9d2a2209c9e6
2020-08-24T18:29:47.510527+00:00 shinyapps[255593]: ���250-smtp.gmail.com at your service, [54.204.34.9]
2020-08-24T18:29:47.510534+00:00 shinyapps[255593]: 250-SIZE 35882577
2020-08-24T18:29:47.510558+00:00 shinyapps[255593]: 250-8BITMIME
2020-08-24T18:29:47.510568+00:00 shinyapps[255593]: 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
2020-08-24T18:29:47.510597+00:00 shinyapps[255593]: 250-ENHANCEDSTATUSCODES
2020-08-24T18:29:47.510612+00:00 shinyapps[255593]: 250-PIPELINING
2020-08-24T18:29:47.510613+00:00 shinyapps[255593]: 250-CHUNKING
2020-08-24T18:29:47.510621+00:00 shinyapps[255593]: 250 SMTPUTF8
2020-08-24T18:29:47.510655+00:00 shinyapps[255593]: ���AUTH LOGIN
2020-08-24T18:29:47.519576+00:00 shinyapps[255593]: ���334 VXNlcm5hbWU6
2020-08-24T18:29:47.519619+00:00 shinyapps[255593]: ���CXdvb2RkYW0ucm9ib3Q=
2020-08-24T18:29:47.528622+00:00 shinyapps[255593]: ���d29vZGRhbWlzd29ya2luZw==
2020-08-24T18:29:47.528582+00:00 shinyapps[255593]: ���334 UGFzc3dvcmQ6
2020-08-24T18:29:47.971499+00:00 shinyapps[255593]: ����¾534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbs
2020-08-24T18:29:47.971506+00:00 shinyapps[255593]: 534-5.7.14 zOP95z_CCyJ4WiVXJggakzlnlj1Ho0edSYinpaBuuEtm377-hwvKQqQNUEiEKKcrKbMCs
2020-08-24T18:29:47.971519+00:00 shinyapps[255593]: 534-5.7.14 j1xiRcO5rqh-FYc0SZB91bBbPelY0UkdYyGo2xUT-klCtjz6j-lrIeNtioKRLh_I>
2020-08-24T18:29:47.971528+00:00 shinyapps[255593]: 534-5.7.14 Please log in via your web browser and then try again.
2020-08-24T18:29:47.971537+00:00 shinyapps[255593]: 534-5.7.14 Learn more at
2020-08-24T18:29:47.971545+00:00 shinyapps[255593]: 534 5.7.14 https://support.google.com/mail/answer/78754 a135sm4481992qkg.71 - gsmtp
2020-08-24T18:29:47.971586+00:00 shinyapps[255593]: Closing connection 0
2020-08-24T18:29:47.971638+00:00 shinyapps[255593]: ���TLSv1.2 (OUT), TLS alert, Client hello (1):
2020-08-24T18:29:47.975133+00:00 shinyapps[255593]: �Warning: Error in curl_fetch_memory: Login denied
2020-08-24T18:29:47.985379+00:00 shinyapps[255593]: 99: curl_fetch_memory
2020-08-24T18:29:47.985380+00:00 shinyapps[255593]: 98: send_mail
2020-08-24T18:29:47.985381+00:00 shinyapps[255593]: 97: smtp
2020-08-24T18:29:47.985382+00:00 shinyapps[255593]: 84: observeEventHandler [/srv/connect/apps/data_submission/app.R#50]
2020-08-24T18:29:47.985382+00:00 shinyapps[255593]: 13: runApp
2020-08-24T18:29:47.985382+00:00 shinyapps[255593]: 12: fn
2020-08-24T18:29:47.985383+00:00 shinyapps[255593]: 7: connect$retry
2020-08-24T18:29:47.985383+00:00 shinyapps[255593]: 6: eval
2020-08-24T18:29:47.985391+00:00 shinyapps[255593]: 5: eval
I tried re-logging into the "from" gmail account, and I ensured that less secure app access is turned on. I suspect this may be an SSL configuration problem in terms of my server() call when I define the smtp object, but I'm not sure why it would work locally and then not work on the server - maybe there's something being created by server() or smtp() in my working directory that I'm not seeing and that isn't being created on the shiny server? Any help would be greatly appreciated.
Add glue
argument to text()
and html()
which will use {glue}
to perform interpolation on message body.
glue
is TRUE
then use variables from enclosing scope.glue
is an environment then use variables from environment.The work for this could be done in check_message_body()
.
Hi there!
I have been playing around with your package and have really been enjoying how it works.
Is there any way to bold/underline text sent in an email written? Or would I need a different package for that?
Thanks!
Hi,
When trying to send an email with both a body message and an attachment, the package sends only one of them (the first one insert).
Here an example where it will only send the body but not the attachment.
email <- envelope() %>%
from("[email protected]") %>%
to("[email protected]") %>%
subject("subject") %>%
body("<b>Hello!</b>", "html") %>%
attachment('data/hist.png')
Hi. I´m using Emayili to send a large number of emails retrieving information from a very large spreadsheet. My code worked for the first 2 emails, but then I staretd getting this error:
553 5.1.3 The recipient address is not a valid RFC-5321 address
Any thoughts? Thanks!
Just tried the package. I'm try to send rmarkdown html output. The code looks like the following.
library(rmarkdown)
library(emayili)
library(magrittr)
library(readr)
email <- envelope()
body_content <- render("email.Rmd")
email <- email %>%
from("[email protected]") %>%
to("[email protected]") %>%
cc("[email protected]") %>%
subject("test emayili!") %>%
body(readr::read_file(body_content), type = "html")
smtp <- server(host = "smtp.gmail.com",
port = 465,
username = "[email protected]",
password = "bd40ef6d4a9413de9c1318a65cbae5d7")
smtp(email, verbose = TRUE)
I checked the inbox and find the css style is not working.
Yesterday we recieved this alert from microsoft:
This is an important communication about the future supported options for Outlook integration for Dynamics 365 and Power Apps.
The Microsoft Dynamics 365 for Outlook integration (also known as Outlook COM add-in) is deprecated. Please plan to transition to the Dynamics 365 App for Outlook before October 1, 2020. Microsoft will continue to provide support, security and other critical updates to the Outlook COM add-in until October 1, 2020 but will not release any additional functionality beyond what has already been announced. For additional information about this change, please visit our blog.
Does this affect you?
Hi, thanks for a nice package. I'm just dropping by to suggest that you add a NEWS/NEWS.md
file with info on what's been added/removed/fixed in new releases.
Thank you for this amazing package!!! I got it working perfectly on our server, but when I try to get it running on my Mac, I'm having some problems. The e-mail sends without a hiccup (the from(), to(), and subject() parts of the envelope() all work. But it's sending an empty e-mail - the text() doesn't show up (though it does when I use the same code on our server). E.g.:
email <- envelope() %>%
from("[email protected]") %>%
to("[email protected]") %>%
subject("This is a plain text message!") %>%
text('Hello!')
I've tried adding disposition and charset options, but they didn't seem to help. Any thoughts on what might be going on?
Thanks again!!
The recent merge of PR #16 causes the the same cid
value to be used for all files attached via a single call to attachment()
e.g.
attachFilenames <- c("file1.png", "file2.png")
email <- email %>%
attachment(attachFilenames)
This causes some mail clients (notably the MacOS mail app) to show only the last file, multiple times.
A workaround is to attach one file at a time: e.g.
for (i in seq_along(attachFilenames)) {
email <- email %>%
attachment(attachFilenames[i])
}
Hi, Im working with twitteR, tidyverse and Emayili.
When i run the script just with tidyverse and Emayili, it send perfectly the email. But when I run the script with twitteR, it give me this notification.
"Error: glue cannot interpolate functions into strings.
* object 'name' is a function."
here an example of my scrip.
library(twitteR);library(tidyverse);library(emayili)
consumerkey <- "*************"
consumersecret <- "*************"
accesstoken <- "*************"
accessTokenSecret <- "*************"
setup_twitter_oauth(consumerkey, consumersecret, accesstoken, accessTokenSecret)
SEARCH1 = twitteR::searchTwitter('search', n = 1000, resultType="recent") %>%
strip_retweets()
SEARCH1 = twitteR::twListToDF(SEARCH1)
teste <- envelope() %>%
from("[email protected]") %>%
to("[email protected]") %>%
subject("text tet") %>%
html('<p>hi</p>')
smtp <- server(host = "***",
port = 25,
username = "***",
password = "***")
smtp(teste, verbose = TRUE)
)
any idea about what happening?
THANKS!
Thanks for this very promising package!
Unfortenately I work on a restricted machine on whicht RTools is not allowed to be installed. (don't ask me why).
Is it possible to install the development version of curl and your package emayili without having to use Rtools?
Hi,
Thanks for the package. Starting to use it, and ran into the following error:
> smtp(out_email)
Error in send_mail(mail_from = msg$header$From, mail_rcpt = recipients, :
could not find function "send_mail"
After some research, I learned that send_mail
comes from the curl package, which doesn't have this function until version 4.0.0. Could I suggest you specify 4.0.0 as the minimum version for curl
in your DESCRIPTION
file in order in order to get the package to install correctly? Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.