MATLAB Function Reference |
Send e-mail message to list of e-mail addresses
Syntax
Description
sendmail('recipients','subject')
sends e-mail to recipients
with the specified subject
. For recipients
, use a string for a single address, or a cell array of strings for multiple addresses.
sendmail('recipients','subject','message','attachments')
sends message
to recipients
with the specified subject
. For recipients
, use a string for a single address, or a cell array of strings for multiple addresses. For message
, use a string or cell array. When message
is a string, the text automatically wraps at 75 characters. When message
is a cell array, it does not wrap but rather each cell is a new line. To force text to start on a new line in strings or cells, use 10
, as shown in the Example of sendmail with New Lines Specified. Specify attachments
as a cell array of files to send along with message
.
To use sendmail
, you must set the preferences for your e-mail server (Internet SMTP server) and your e-mail address must be set. MATLAB tries to read the SMTP mail server from your system registry, but if it cannot, it results in an error. In this event, identify the outgoing mail server for your electronic mail application, which is usually listed in the application's preferences, or, consult your e-mail system administrator. Then provide the information to MATLAB using
If you cannot easily determine your e-mail server, try using mail
, as in
which might work because mail
is often a default for mail systems.
Similarly, if MATLAB cannot determine your e-mail address and produces an error, specify your e-mail address using
Example of sendmail with Two Attachments
sendmail('user@otherdomain.com','Test subject','Test message', {'directory/attach1.html','attach2.doc'});
Example of sendmail with New Lines Specified
This mail message forces the message to start new lines after each 10
.
sendmail('user@otherdomain.com','New subject', ... ['Line1 of message' 10 'Line2 of message' 10 ... 'Line3 of message' 10 'Line4 of message']);
semilogx, semilogy | set |
© 1994-2005 The MathWorks, Inc.