September 17, 2015
Matlab Send Email
I have interesting with how to send email from Matlab. This is a simple code how to send email from Matlab using Yahoo mail. You can change the host server name and port to other if want use other email host. Try to search at search engine to get smtp and port from other email.
function sendMessage(senderAddress, senderPassword, receiverAddress, ... m_subject, m_text) % senderAddress : sender email address (use Yahoo mail) % senderPassword : sender email password) % receiverAddress : receiver email or phone number % m_subject : message subject % m_text : text message % How to use : % sendMessage('youremail@yahoo.co.id', 'yourpassword', 'email/phone number', 'subject', 'your message'); host = 'smtp.mail.yahoo.com'; port = '465'; setpref( 'Internet','E_mail', senderAddress ); setpref( 'Internet', 'SMTP_Server', host ); setpref( 'Internet', 'SMTP_Username', senderAddress ); setpref( 'Internet', 'SMTP_Password', senderPassword ); props = java.lang.System.getProperties; props.setProperty( 'mail.smtp.user', senderAddress ); props.setProperty( 'mail.smtp.host', host ); props.setProperty( 'mail.smtp.port', port ); props.setProperty( 'mail.smtp.starttls.enable', 'true' ); props.setProperty( 'mail.smtp.debug', 'true' ); props.setProperty( 'mail.smtp.auth', 'true' ); props.setProperty( 'mail.smtp.socketFactory.port', port ); props.setProperty( 'mail.smtp.socketFactory.class', 'javax.net.ssl.SSLSocketFactory' ); props.setProperty( 'mail.smtp.socketFactory.fallback', 'false' ); sendmail( receiverAddress , m_subject, m_text );
We can use this function (send email from Matlab using Yahoo mail) using command :
sendMessage('youremail@yahoo.co.id', 'yourpassword', 'email/phone number', 'subject', 'your message');