Monday, March 27, 2006

Sending Mails....

A Year Back Our group was in Turmoil of anonymous person sending mails which were unwanted. These mails would contain the names of the group members as the sender, but were sent by the some other person who was solely interested in disrupting the unity of the group.
I had always said it was not a very tough task to do those things. You might have come to sites such as 123greetings.com which send greeting to your friends if you mention your mail-id.

Well all of my given ways would require an SMTP server for Re-direction of mails. The codes cannot change Senders IP Address but can Change the Name. I had many things on my mind by which you can send mails being anonymous. Well some of those can be:-

1. From a Web server (By Some Java API)
2. From a Database Server (By a simple Oracle Procedure)
3. through Outlook.
4. By some Visual Basic features.
5. Sites which offer these facilities.

Of this the easiest one would be 3 & 4 Case.

Here's a code of the Oracle Procedure which will mail to the specified Person. You just need to execute the command from your SqlPlus or any PL/Sql Editor/IDE.

create or replace procedure send_mail (
sender IN VARCHAR2,
recipient IN VARCHAR2,
subject IN VARCHAR2,
message IN VARCHAR2)
IS
v_host_name VARCHAR2(100);
v_host_ip VARCHAR2(100);
v_message varchar2(1000);
crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );

mail_conn utl_smtp.connection;
BEGIN
v_host_name := utl_inaddr.get_host_name();
v_host_ip := utl_inaddr.get_host_address(v_host_name);
mail_conn := utl_smtp.open_connection('localhost', 25);

utl_smtp.helo(mail_conn, v_host_ip);
utl_smtp.mail(mail_conn, sender);
utl_smtp.rcpt(mail_conn, recipient);

v_message := 'Date: ' || TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss' ) || crlf ||
'From: ' || sender || crlf ||
'Subject: ' || subject || crlf ||
'To: ' || recipient || '>' || crlf ||
'' || crlf || message;


utl_smtp.data(mail_conn, v_message);
utl_smtp.quit(mail_conn);
dbms_output.put_line('Mail Gaya Bhai Log');
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error Ho Gaya');
END;



To execute this procedure:-

execute send_mail('sender'sID','recipientID','subject','message' )

Soon I think I will Test the codes for Java & Visual Basic, And the article would be complete.

No comments:

Java 10 Features

My blog post in JournalDev for Java 10 Features