The STMP service can be used to send emails to a specified email address through some of Matlab’s own functions. When running a large program, it can be used to notify the program that it has finished running or that there has been an error. Furthermore, Matlab supports the sending of results files saved by the program as attachments. This is also an indirect way of backing up the results.
Sending an email via Matlab is mainly the following code
1 | sendmail(receiver,mailtitle,[mailcontent,filePath]); |
It contains four parameters, receiver
refers to the incoming mailbox, mailtitle
is the subject of the message, mailcontent
is the body content of the message, and filePath
is the attachment file, I use the absolute path to the file. All four of these parameters are string types.
Of course there are some other settings needed to send the mail, and the encapsulated function is as follows.
1 | function mailMe(mailcontent,filePath,mailtitle) |
In this way, you can send emails with attachments to the specified mailbox.
Note that attachments should not exceed 30mb in general, although China’s 163 and QQ mailboxes both support attachments of 50mb in size, but if the sender’s mailbox is one of these two, the password set is not your original password but an ‘authorisation code’. You can find it in “Settings” or “Security and Password” of your mailbox. The incoming mailbox is recommended to choose QQ mailbox, when the new mail comes, you can be reminded by QQ and WeChat, and there is unlimited mailbox space. Or mobile phone mailboxes from various operators are also good, with 100 or 200 free mailbox SMS alerts per month. You can receive messages from the program in real time.