Sending Email thorugh MATLAB
Electronic mail or E-mail is around us since 1993. The pioneer of this mode of communication was no doubt 'Hotmail' which is now owned by Microsoft. From computer based application, they have taken it to web and publicize it to an extent that today the official communication seems incomplete without it. Although the first of the web email was sent through a CERN project.
|Sending Email thorugh MATLAB|
In this MATLAB code I have used MATLAB JAVA classes to use their SMTP access property. For more about EMAIL and SMTP or other protocols which is used to send mails please refer web.
The MATLAB is commented well, but if you have any doubt please comment below. MATLAB code in bold for better contrast from the comments.
%%MATLAB Code for Sending Email %%
clc;close all;clear all;
email@example.com'; %replace with your choice of mail id
%set service='yahoo' for yahoo.com
%set service='gmail' for gmail.com
%set service='live' for live.com
%set service='outlook' for outlook.com
%set service='anyother' for anyother.com
%set ext='.com' for .com domain
%set ext='.in' for .in domain
%set ext='.co.in' for .co.in domain
%set ext='.mobi' for .mobi domain
%set ext='.xyz' for .xyz domain
user_name='vibhutesh1494'; %replace the string with your user name
password='xyz'; %replace the string with your password (sender's password)
subject='Anything you want'; %replace the string with subject of your mail
%if you want subject be blank simply make subject=''
body='Type you email content here'; %replace it with content of your mail
%if you want to send a blank mail simply make body=''
attachment='Provide full path of the file to be attached';
%if you dont want to attach anything simply replace attachment='Path' by attachment=
%setting up email server by using java classes
props = java.lang.System.getProperties;
%Change this to port 25, 465, 587, 995 based on server properties
%port 25 for smtp
%port 465 for secured/encrypted smtp
%port 587 for TLS enabled servers
%port 995 for SSL/TLS encrypted POP
% add in different cases based on server settings
id = [user_name,'@gmail.com'];
id = [user_name,'@live.com'];
id = [user_name,'@outlook.com'];
id = [user_name,'@yahoo.com'];
id = [user_name,'@',service,'.com'];
%for login through your smtp settings
*Your mail could end up in SPAM folder particularly if you end up using port 25, so be sure to check this folder too.
*You must be connected to internet for using this code.
*For Gmail it is required to have a secure connection by default. If you get a security certificate error try fiddling up something in your GMAIL account setting to make the mailing transaction unsecured. (At-least for this program).