Main Content

sendmail

Send email message to address list

Description

sendmail(recipients,subject) sends an email to the specified recipients with the specified subject.

Note

sendmail does not support major email providers such as Gmail and Microsoft® Outlook®. sendmail only supports email servers with Basic username-password based authentication and Transport Layer Security (TLS) 1.0. For more information, see Set Preferences.

example

sendmail(recipients,subject,message) includes the specified message.

example

sendmail(recipients,subject,message,attachments) attaches the files listed in attachments.

example

Examples

collapse all

Send a message with two attachments to an email address:

sendmail('user@otherdomain.com',...
         'Test subject','Test message',...
         {'folder/attach1.html','attach2.doc'});

Send a message with forced line breaks (using 10) to an email address:

sendmail('user@otherdomain.com','New subject', ...
        ['Line1 of message' 10 'Line2 of message' 10 ...
         'Line3 of message' 10 'Line4 of message']);

The resulting message is:

Line1 of message
Line2 of message
Line3 of message
Line4 of message

Input Arguments

collapse all

Recipients of email, specified as a string scalar, string array, character vector, or cell array of character vectors. For a single recipient, specify recipients as a character vector or a string. For multiple recipients, specify recipients as a cell array of character vectors or a string array.

Subject line of email, specified as a string scalar or character vector.

Message text of email, specified as a string scalar, string array, character vector, or cell array of character vectors. If message is a character vector or a string, sendmail automatically wraps text at 75 characters. To force a line break in the message text, use 10. If message is a cell array of character vectors or a string array, then each element represents a new line of text.

sendmail does not support HTML-formatted messages. However, you can send HTML files as attachments.

Attached files, whose file paths are specified as a string scalar, string array, character vector, or cell array of character vectors.

More About

collapse all

Tips

Version History

Introduced in R2006a