This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Send email message to address list




sendmail(recipients,subject) sends email to recipients with the specified subject. The recipients input is a character vector for a single address, or a cell array of character vectors for multiple addresses.

sendmail(recipients,subject,message) includes the specified message. If message is a character vector, sendmail automatically wraps text at 75 characters. To force a line break in the message text, use 10, as shown in the Examples. If message is a cell array of character vectors, each cell represents a new line of text.

sendmail(recipients,subject,message,attachments) attaches the files listed in the character vector or cell array attachments.


Send a message with two attachments to a hypothetical email address:

         'Test subject','Test message',...

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

sendmail('','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


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

  • If sendmail cannot determine your email address or outgoing SMTP mail server from your system registry, specify those settings using the setpref function. For example:


    To identify the SMTP server for the call to setpref, check the preferences for your electronic mail application, or consult your email system administrator. If you cannot easily determine the server name, try 'mail', which is a common default, such as:

  • By default, the sendmail function does not support email servers that require authentication. To support these servers, change your system settings and set preferences for the SMTP user name and password, with commands in the following form:

    props = java.lang.System.getProperties;
  • To override the default character encoding, set the preference for email character encoding as follows:

    where encoding is a character vector specifying the character encoding, such as 'SJIS'.


On Windows® systems with Microsoft® Outlook®, you can send email directly through Outlook by accessing the COM server with actxserver. For an example, see Solution 1-RTY6J.

Was this topic helpful?