Send email from Matlab!

Support for contact nicknames, attachment of figures, m-files, and any file on the path.
Updated 4 Dec 2012

View License

Before first use, type 'fn_email setserver', you will be prompted for your e-mail address and SMTP server settings.

Then, to send an e-mail from Matlab, just type 'fn_email', you will be prompted for:

* recipients: press Enter after each recipient, press Enter twice to continue; if you want to define a nickname, type the nickname that you want, you will then be prompted for the address to associate with this nickname

* subject

* figures to attach: type the list of figures that you want to attach then press Enter; each figure will be saved as both a jpg and an eps file; you will have to manually edit fn_email.m if you want another format

* m-file or file to attach: press Enter after each file you want to enter, press Enter twice to continue; the function uses 'which' to find the file, therefore you do not need to put the .m extension for m-files, and you can give the name of any file on the path (and not only in the current directory); naturally, you can also enter an absolute path

* text: separate lines of text by pressing Enter; pressing Enter twice will leave a blank line, while pressing Enter three time means you finished to type the tex

* send mail now?: press Enter to send immediately, type 'n' and Enter to not send immediately; in such case, the function returns a cell array that you can edit and later send with Matlab function sendmail the following way:

C = ans; % this puts the email content in variable C
% you can do some changes to C
sendmail(C{:}) % send the email

Cite As

Thomas Deneux (2024). Send email from Matlab! (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

compatibility with R2012a