sendmail - Send e-mail message to address list

Syntax

sendmail('recipients','subject')
sendmail('recipients','subject','message','attachments')

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. The MATLAB software 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:

setpref('Internet','SMTP_Server','myserver.myhost.com');

If you cannot easily determine your e-mail server, try using mail, as in:

setpref('Internet','SMTP_Server','mail');

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:

setpref('Internet','E_mail','myaddress@example.com');

Examples

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']);

The resulting message is:

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

See Also

getpref, setpref

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS