Learn R Programming

emayili (version 0.4.4)

server: Create a SMTP server object.

Description

Create a SMTP server object.

Usage

server(
  host,
  port = 25,
  username = NULL,
  password = NULL,
  insecure = FALSE,
  reuse = TRUE,
  ...
)

Arguments

host

DNS name or IP address of the SMTP server.

port

Port that the SMTP server is listening on.

username

Username for SMTP server.

password

Password for SMTP server.

insecure

Whether to ignore SSL issues.

reuse

Whether the connection to the SMTP server should be left open for reuse.

...

Additional curl options. See curl::curl_options() for a list of supported options.

Value

A function which is used to send messages to the server.

Examples

Run this code
# NOT RUN {
library(magrittr)

# Set parameters for SMTP server (with username and password)
smtp <- server(host = "smtp.gmail.com",
               port = 465,
               username = "bob@gmail.com",
               password = "bd40ef6d4a9413de9c1318a65cbae5d7")

# Set parameters for a (fake) testing SMTP server.
#
# More information about this service can be found at https://www.smtpbucket.com/.
#
smtp <- server(host = "mail.smtpbucket.com",
               port = 8025)

# Create a message
msg <- envelope() %>%
  from("bob@gmail.com") %>%
  to("alice@yahoo.com")

# Send message (verbose output from interactions with server)
# }
# NOT RUN {
smtp(msg, verbose = TRUE)
# }
# NOT RUN {
# To confirm that the message was sent, go to https://www.smtpbucket.com/ then:
#
# - fill in "bob@gmail.com" for the Sender field and
# - fill in "alice@yahoo.com" for the Recipient field then
# - press the Search button.
# }

Run the code above in your browser using DataLab