Skip to contents

Sends a contact form email from a gallery visitor to an artist using the Resend API. This is a pure email sending function with no database dependencies.

Usage

send_contact_email(
  to,
  visitor_name,
  visitor_email,
  msg,
  from = NULL,
  subject = NULL,
  art_title = NULL,
  art_url = NULL
)

Arguments

to

Artist email address (recipient)

visitor_name

Name of the person sending the message

visitor_email

Email address of the person sending the message

msg

The message content from the visitor

from

Optional. Sender email address (defaults to configured sender)

subject

Optional custom subject line. Auto-generated if NULL

art_title

Optional. Title of the artwork being viewed

art_url

Optional. URL to the artwork thumbnail

Value

List with response details from Resend API:

success

Logical indicating if email was sent successfully

message_id

Email ID from Resend (if successful)

error

Error message (if unsuccessful)

Details

This function:

  • Validates all input parameters

  • Builds professional HTML email template

  • Sends via Resend API with Reply-To header

  • Returns success/failure status

Requires environment variable ART_RESEND_KEY to be set with a valid Resend API key.

Examples

if (FALSE) { # \dontrun{
# Set API key first
Sys.setenv(ART_RESEND_KEY = "re_xxxxxxxxxxxxx")

# Send contact email
result <- send_contact_email(
  to = "artist@example.com",
  visitor_name = "John Doe",
  visitor_email = "john@example.com",
  msg = "I love your artwork! Can we discuss a commission?",
  art_title = "Sunset Dreams",
  art_url = "https://cdn.artalytics.app/..."
)

if (result$success) {
  message("Email sent! ID: ", result$message_id)
} else {
  warning("Failed: ", result$error)
}
} # }