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.
See also
get_resend_config()for API configurationvalidate_email_fmt()for email validationsend_wp_email(),send_waitlist_confirm()for other email types
Other email-sending:
send_artist_invite(),
send_investor_welcome(),
send_metrics_admin(),
send_metrics_confirm(),
send_metrics_granted(),
send_waitlist_confirm(),
send_wp_email()
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)
}
} # }
