--- title: SMTP description: Instructions on how to add e-mail notifications to Home Assistant. ha_category: - Notifications ha_iot_class: Cloud Push ha_release: pre 0.7 ha_domain: smtp ha_platforms: - notify ha_integration_type: integration --- The SMTP platform allows you to deliver notifications from Home Assistant to an e-mail recipient. To enable notification by e-mail in your installation, add the following to your `configuration.yaml` file: ```yaml # Example configuration.yaml entry notify: - name: "NOTIFIER_NAME" platform: smtp sender: "YOUR_SENDER" recipient: "YOUR_RECIPIENT" ``` Check your e-mail provider configuration or help pages to get the correct SMTP settings. {% configuration %} name: description: Setting the optional parameter `name` allows multiple notifiers to be created. The notifier will bind to the service `notify.NOTIFIER_NAME`. required: false type: string default: notify sender: description: E-mail address of the sender. required: true type: string recipient: description: Default E-mail address of the recipient of the notification. This can be a recipient address or a list of addresses for multiple recipients.
This is where you want to send your E-mail notifications by default (when not specifying `target` in the service call). Any E-mail address(es) specified in the service call's `target` field will override this recipient content. required: true type: [list, string] server: description: SMTP server which is used to send the notifications. required: false type: string default: localhost port: description: The port that the SMTP server is using. required: false type: integer default: 587 timeout: description: The timeout in seconds that the SMTP server is using. required: false type: integer default: 5 username: description: Username for the SMTP account. required: false type: string password: description: Password for the SMTP server that belongs to the given username. Make sure to wrap it in double quotes; e.g., `"MY_PASSWORD"`. required: false type: string encryption: description: Set mode for encryption, `starttls`, `tls` or `none`. required: false type: string default: starttls sender_name: description: "Sets a custom 'sender name' in the emails headers (*From*: Custom name )." required: false type: string debug: description: Enables Debug, e.g., `true` or `false`. required: false type: boolean default: false verify_ssl: description: If the SSL certificate of the server needs to be verified. required: false type: boolean default: true {% endconfiguration %} ### Usage To use the SMTP notification, refer to it in an automation or script like in this example: ```yaml burglar: alias: "Burglar Alarm" sequence: - service: shell_command.snapshot - delay: seconds: 1 - service: notify.NOTIFIER_NAME data: title: "Intruder alert" message: "Intruder alert at apartment!!" target: - "my_intruder_alert@example.com" data: images: - /home/pi/snapshot1.jpg - /home/pi/snapshot2.jpg ``` The optional `target` field is used to specify recipient(s) for this specific service call. When `target` field is not used, this message will be sent to default recipient(s), in this example, my_intruder_alert@example.com. The optional `images` field adds in-line image attachments to the email. This sends a text/HTML multi-part message instead of the plain text default. The optional `html` field makes a custom text/HTML multi-part message, allowing total freedom for sending rich html emails. In them, if you need to attach images, you can pass both arguments (`html` and `images`), the attachments will be joined with the basename of the images, so they can be included in the html page with `src="cid:image_name.ext"`. ```yaml burglar: alias: "Burglar Alarm" sequence: - service: shell_command.snapshot - delay: seconds: 1 - service: notify.NOTIFIER_NAME data: message: "Intruder alert at apartment!!" data: images: - /home/pi/snapshot1.jpg - /home/pi/snapshot2.jpg html: > Intruder alert

Intruder alert at apartment!!

snapshot1
snapshot2

``` To learn more about how to use notifications in your automations, please see the [getting started with automation page](/getting-started/automation/). ## Specific E-Mail Provider Configuration Check below some configurations examples for specific e-mail providers. If you are in doubt about the SMTP settings required, check your e-mail provider configuration or help pages for more information about its specific SMTP configuration. ### Google Mail A sample configuration entry for Google Mail. ```yaml # Example configuration.yaml entry for Google Mail. notify: - name: "NOTIFIER_NAME" platform: smtp server: "smtp.gmail.com" port: 587 timeout: 15 sender: "YOUR_USERNAME@gmail.com" encryption: starttls username: "YOUR_USERNAME@gmail.com" password: "YOUR_PASSWORD" recipient: - "RECIPIENT_1@example.com" - "RECIPIENT_N@example.com" sender_name: "SENDER_NAME" ``` Keep in mind that Google has some extra layers of protection that need special attention. By default, the usage by external applications is limited so you will need to visit the [less secure apps](https://myaccount.google.com/lesssecureapps) page and enable it to be able to send e-mails. Be aware that Google will periodically turn it off if it is not used (no e-mail is sent). To avoid having your e-mail notifications broken due to the less secure app's behavior, it is recommended that you enable 2-step verification on your Google account, and use [an application-specific password](https://support.google.com/mail/answer/185833) in your notification configuration.