> For the complete documentation index, see [llms.txt](https://modern-cfml.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://modern-cfml.ortusbooks.com/beyond-the-100/sending-emails.md).

# Sending Emails

CFML gives you the `cfmail` tag/construct to easily send email in text or HTML format without any ceremony.  Just register your mail servers in the administrators or the `Application.cfc` and you are ready to start sending emails in a jiffy!

```java
cfmail( 
  subject="Your Order", 
  from="myshop@ortus.com", 
  to="whatever@gmail.com,another@gmail.com",
  bcc="orders@ortus.com"
  type="HTML"
){
  // body of the email.
  writeOutput( 'Hi there,' );
  writeOutput( 'This mail is sent to confirm that we have received your order.' );
};
```

The `cfmail` tag/construct has tons of attributes, so check them out in the docs <https://cfdocs.org/cfmail>

### Query Binding

You can even bind the mail construct with a query, and the engine will send as many emails as rows in the query for you:

```java
var qData = userService.getNewUsers();
cfmail( 
  subject="Welcome to FORGEBOX!", 
  from="myshop@ortus.com", 
  to="#qData.email#",
  query=qData
){
  writeOutput( "
    Dear #qData.name#,
    
    Welcome to your FORGEBOX account! Play and just do it!
  ")
};
```

### Sending Attachments

You can also send attachments to your email destinations very easily using the `mimeattach` attribute or via the child `cfmailparam()` construct, which allows you to send multiple attachments, or headers.

```java
cfmail( 
  subject="Your Order", 
  from="myshop@ortus.com", 
  to="whatever@gmail.com,another@gmail.com",
  bcc="orders@ortus.com"
  mimeattach=expandPath( "/my/path/attach.pdf" );
){
  // body of the email.
  writeOutput( 'Hi there,' );
  writeOutput( 'This mail is sent to confirm that we have received your order.' );
};

cfmail( subject="Attachments", to="you@domain.com", from="me@domain.com" ) {
	cfmailparam( name="Reply-To", value="me@domain.com" );
	cfmailparam( file="c:\files\readme.txt" );
	cfmailparam( file="c:\files\logo.gif" );
}
```

{% hint style="success" %}
More in-depth information can be found here: <https://helpx.adobe.com/coldfusion/developing-applications/using-external-resources/sending-and-receiving-e-mail/sending-e-mail-messages.html>
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://modern-cfml.ortusbooks.com/beyond-the-100/sending-emails.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
