Send a mail using smtp server

i'm new to java mail api
i'm using a machine which is in a network under a proxy server and a fire wall.our network has a smtp server.
i tried to send a amil using a smtp server.
my codes are
package mailtest;
import java.util.Properties;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.InternetAddress;
import javax.mail.MessagingException;
import java.io.*;
import javax.mail.Message;
import javax.mail.Transport;
public class FirstMail {
String mailServer;
String host;
public FirstMail() {
//global
mailServer="mail.smtp.host";
host="mail.informatics.lk";
// Get system properties
Properties myProperties=new Properties() ;
// Setup mail server
myProperties.put(mailServer,host) ;
myProperties.put("mail.smtp.auth", "true");
// Get session
Session myMailSession;
myMailSession=Session.getInstance(myProperties,null);
//myMailSession.setDebug(true);
// Define message
MimeMessage message=new MimeMessage(myMailSession);
// Set the from address
//try {
try {
message.setFrom(new InternetAddress("[email protected]","CHANAKA ARUNA"));
catch (UnsupportedEncodingException ex1) {
System.out.println("CAN NOT SEND FROM");
catch (MessagingException ex1) {
System.out.println("CAN NOT SEND FROM");
// Set the to address
try {
message.addRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
catch (MessagingException ex) {
System.out.println("CAN NOT SEND TO");
// Set the subject
try {
message.setSubject("RE:$$$$");
catch (MessagingException ex2) {
System.out.println("WRONG SUBJECT");
// Set the content
try {
message.setText("***chanaka***");
catch (MessagingException ex3) {
System.out.println("WRONG MESSAGE");
// Send message
try {
Transport.send(message);
System.out.println("MESSAGE SENT");
catch (MessagingException ex4) {
System.out.println("UNABLE TO SEND");
public static void main(String[] args) {
FirstMail firstMail1 = new FirstMail();
it was not work, but when i use the ip address of smtp server instead of mail.informatics.lk at
host="mail.informatics.lk";
it worked properly and i could get a mail to my yahoo address.
but i have seen some have used host name like
host="smtp.snet.yahoo.com";
how can i do it using yahoo smtp server.
also i want to know whethr i can use that our smtp server from a computer outside of the net work.
pls help me
txs lot.

Almost certainly, if you are behind a proxy server it will only be a proxy for HTTP traffic, and you will not be able to communicate with an SMTP server outside your network. But you have your own SMTP server so why would you want to?
If you have a proxy server and an SMTP server then there will be people responsible for supporting them. Talk to those people and ask them to give you the basic explanation of networking that you need.

Similar Messages

  • SMICM error while sending mail using SMTP server

    Hi All,
    We are not able send mails using SMTP server.
    We have made every settings necessary in SCOT, SO16 , SMTP service is activated, default domain is maintained etc
    Only things which seems to be wrong is in SMICM trace file.
    [Thr 13] *** ERROR => NiBufIConnect: non-buffered connect pending after 5000ms (hdl 29;10.26.24.44:1090) [nibuf.cpp    4608]
    [Thr 13] *** WARNING => Connection request from (0/1/0) to host: 10.26.24.44, service: 1090 failed (NIECONN_REFUSED)
    [icxxconn_mt.c 2321]
    This error is getting repeated in it.
    BUt I am not sure why it it trying to hit 10.26.24.44, as we dont have any server by this ip. The ip is only not resolvable from the server.
    1 more thing, at OS level, following parameter is maintained in profile :
    icm/server_port_1 = PROT=SMTP,PORT=25000,TIMEOUT=180
    But in SCOT, under SMTP node PORT is given as 25.
    Kindly let me know what going wrong here?
    Thanks

    also getting error as follows
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1
    Authentication Required. Learn more at
       at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
       at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
       at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
       at System.Net.Mail.SmtpClient.Send(MailMessage message)
       at ST_c121e07caaa94c21bb1355d4f753112f.vbproj.ScriptMain.Main()
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
       at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

  • Does SAP can send a mail thru smtp server ?

    Hello everybody ,
            Does sap 4.7 can write a abap program to send a mail thru another smtp server (ex:lotus notes) ?
            because of i hav' t any basis authorzation .
    Thanks in advanced,
    Best Regards,

    Hi,
    As far as i know , it is not possible to send a mail through external server (lotus notes).
    If u dont have the authorizations then just check it with ur BASIS guy.. he can provide u with the same..
    Cheers,
    Simha.

  • Can someone help me send mail using SMTP server?

    I am having the most frustrating problem with SMTP outgoing email account.  I use GoDaddy's Webmail (smtp.secureserver.net) and I receive all my emails through Apple Mail but I cannot send any.  I haven't been able to for about two weeks now, aside from 3 or 4 fleeting windows of time when I could.  Almost all of the time I try to send my emails, an error message says my outgoing account is offline.  I've been on the phone with GoDaddy's tech support three times this week and did everything we could think of, which include these steps:
    -Force Quit Apple Mail --> Restart Computer
    -Change Default Ports to a specific one and uncheck "Use Secure Sockets Layer (SSL)"
    -Check "Use only this server"
    -Delete account completely from Apple Mail and re-load (which I had to go into Time Machine to recover messages, and lots a bunch in the process ugh!)
    Nothing works!  I depend on this email for my business, and I rely heavily on Apple Mail for this account.  All of my other email accounts that I pull through Mail work fine, but of course they are not SMTP outgoing.  Please help...I feel like I've tried everything and nothing works permanently. 

    At this point there are 2 possible causes to your problem:
    Apple Mail
    Connectivity between you and the SMTP server
    I can't help with (1) as I use Thunderbird as my mail client (the biggest advantage being I can take my mail files and move between different versions of Mac OS X). If you suspect that your problem is due to Apple Mail, then using another email client to send a test message will prove the point. If it works, then the problem lies with Apple Mail and somebody else will have to chip in. If it still fails, then there may be connectivity issue between you and the mail server.
    If you google "telnet smtp test" (without the quotes), you will find many articles showing you how to test an SMTP connection using telnet. Don't be put off by the fact that many of the articles assume you are running Windows. The only Mac bit you need to know is that telnet is a command line utility accessed via Terminal. The rest is generic.
    Telnet will allow you to interact with the mail server a line at a time and show you exactly what and where the problem is. If you get an unexpected response from the server, go back to GoDaddy and show them the output. If you don't get any response at all (i.e. "telnet smtpout.secureserver.net 25" just hangs), then take it up with your ISP as you are simply not getting through to the server.
    Good luck.

  • Sending mail using smtps protocol

    Could anyone post a piece of code to show how to send a message using smtps protocol?
    SSLNotes of 1.3.2ea version say that it's possibile, but i tried whithout success....
    Thanks

    Hello,
    I can send the mail using SMTP with the help of java mail api. But i want to send mail using SMTPS protocol using java. The mail should be encrypted format.
    So, my queries are:
    1. How to send mail using SMTPS protocol?
    2. I want to send the mail as encryption mail. So how to create encrypted mail.?
    Thanks in advance.
    From
    Rajendra.

  • What are the prerequisits i need to send a mail using java mail

    i have a class file using javamail.
    I want to validate the email id's and send to particular address.
    will u please tell me the process and prerequisits to send the mail(like SMTP server,username ,password..)
    Please what actually username , password is ment in an authenticated javamail program.
    is it user account on SMTP server / email id
    Thanks.
    Prasantha Reddy C

    Hi,
    you need your smtp host address and smtp user name and password to send emails out.
    and yes the user name and password are the smtp username and password for authentication
    regards
    shyam

  • How to bypass proxy when trying to send a mail using javamail smtp

    Hi,
    I am trying to make a servlet send a mail using javamail smtp protocol on port 25 but i m not able to send getting an exception, i suspect proxy is blocking, so any idea anyone how bypass a proxy.

    And if it does turn out that there's a proxy server blocking access to your target SMTP server, the best way to deal with that is to discuss the issue with the person responsible for your network configuration.

  • I send mail via SMTP server with Hebrew text, and I get it gibberish on my iphone

    I send mail via SMTP server with Hebrew text, and I get it gibberish on my iphone

    What mail program from what kind of computer are you sending your email?  It sounds like an encoding problem that would have to be solved on the sending end.   If you want, send me an example of the kind of email which arrives as gibberish on your iphone (tom at bluesky dot org).

  • Sending Mail through SMTP server

    Hi
    I am trying to sent the mails through smtp server but but my smtp server is not reponding, I tried to delete the account & recreated the accounts & the smtp server but unable to do that, but creating the same mail account & same smtp server works in different laptop. can any one guide me how to correct the problem & repair it.
    Thanks in advance for the support.

    There are a couple of things you might check:
    make sure that you have the server name entered correctly (for example, stmp.gmail.com)
    make sure that if you have to override the default port that you have
    make sure that if SSL is required to connect that you've this option ticked, and
    make sure that if you need to provide a user name and password to access the server that you have.
    Other than that, that's about all that I can think of.
    Clinton

  • Unable to sending a mail using odisend mail

    Hi,
    i have a need to send a mail using odi send mail, i am using gmail server getting to send a mail, but it getting error like this
    com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. d19sm1563829ibh.8
         at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
         at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
         at javax.mail.Transport.send0(Transport.java:169)
         at javax.mail.Transport.send(Transport.java:99)
         at com.sunopsis.dwg.tools.SendMail.actionExecute(SendMail.java:220)
         at com.sunopsis.dwg.function.SnpsFunctionBase.execute(SnpsFunctionBase.java:276)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execIntegratedFunction(SnpSessTaskSql.java:3430)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.executeOdiCommand(SnpSessTaskSql.java:1491)
         at oracle.odi.runtime.agent.execution.cmd.OdiCommandExecutor.execute(OdiCommandExecutor.java:32)
         at oracle.odi.runtime.agent.execution.cmd.OdiCommandExecutor.execute(OdiCommandExecutor.java:1)
         at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2906)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2609)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:540)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:453)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1740)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:338)
         at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:214)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:272)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:263)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:822)
         at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:123)
         at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:83)
         at java.lang.Thread.run(Thread.java:662)
    please share your opinions for this post
    Regards,
    901202

    http://www.oracle.com/technetwork/java/javamail/faq/index.html#starttls

  • Sending e-mail using utl_smtp on oracle 9i

    Hello
    I have problem with sending e-mails using utl_smtp package.
    My code looks like this:
    lv_mail_conn := utl_smtp.open_connection(lv_mailhost_txt);
    utl_smtp.ehlo(lv_mail_conn, lv_mailhost_txt);
    res :=     utl_smtp.command(lv_mail_conn, 'AUTH LOGIN');
    res := utl_smtp.command(lv_mail_conn, <login in base64>);
    res := utl_smtp.command(lv_mail_conn, <password in base64>);
    And I get en error after sending a password to SMTP server.
    Error code: 535, text: 5.7.3 Authentication unsuccessful.
    This happens on oracle 9i.
    I have another server for testing which has oracle 10g installed. This code works fine on oracle 10g but doesn't work on oracle 9i.
    Do you have any ideas what's wrong? I assume that SMTP server (microsoft exchange) work correctlys because I can send e-mail from test server.

    Ok problem solved :)
    Problem was between oracle and MS exchange server. Live server oracle 9i is on linux, and testing server works on windows.
    So the problem was with configuration. Our admins corrected it and now works :). I don't know details.

  • Problem to send e-mails from bo server

    Hi!!!
    I want to send some webi reports from my bo server to a email addres, but it show me the following message:
    address error. [Error sending address(es) to SMTP server. Return code: [SMTP 550 - Requested action not taken: mailbox unavailable.]. Reason: [email addres].]: [CrystalEnterprise.Smtp]
    Can you help me please??
    Ruddy Alvarado

    We are facing the same issue
    server error. [CrystalEnterprise.Smtp]: [Error initializing SMTP server. Return code: [TCP send failed.]. Reason: [XXXX.XXXX.XXXX:25].]
    - I tried with FQDN, IP address of SMTP server
    - I was able to send e-mail to myself from command line useing telnet xxxxx.xxx.xxx 25 (so that means port 25 is open and communication is happening between BO servers to SMTP server
    - No firewalls on BO servers (2008 VMware)
    - Antivirus has been disabled on these servers (just to see if that is blocking anything)
    What else I can check with my SMTP admin.
    Anybody here has any ideas? Appreciate your inputs.
    -- Nivas

  • Sending php mail(); using postfix. Authentication failed.

    Trying to set up my localhost to send php mail() using postfix.
    I did the following:
    Created the sasl_passwd file
    Created the sasl_passwd.db file
    Edited mail.cf in the postfix folder to include relay host: relayhost=smtp.live.com:587
    I'm trying to relay through my hotmail account. The mail.log returns the following:
    Jan 24 13:17:30 Richards-MacBook-Pro.local postfix/error[927]: E75CCE40EE4: to=<[email protected]>, relay=none, delay=1580, delays=1580/0.07/0/0, dsn=4.0.0, status=deferred (delivery temporarily suspended: SASL authentication failed; server smtp.live.com[65.55.162.200] said: 535 5.0.0 Authentication Failed)
    Any ideas what I'm doing wrong here?

    Ok problem solved :)
    Problem was between oracle and MS exchange server. Live server oracle 9i is on linux, and testing server works on windows.
    So the problem was with configuration. Our admins corrected it and now works :). I don't know details.

  • Mail using smtp is going with to field blank

    Hi,
    I am sending a mail using utl_smtp .receipient is getting the mail.but problem is that he is getting it with blank 'to field'.
    Following is the code i wrote.
    CREATE OR REPLACE PROCEDURE mis_test_send_mail AS
    pfrom VARCHAR2(100):='[email protected]';
    crlf CONSTANT VARCHAR2(100):= CHR(13) || CHR(10);
    message VARCHAR2(1000);
    preceiver VARCHAR2(100):='[email protected]';
    psubject VARCHAR2(100):='Test Mail';
    mail_conn Utl_Smtp.connection;
    mailhost CONSTANT VARCHAR2(50):='mailrelay.organization.com';
    BEGIN
    message:='How Are You'||crlf;
    mail_conn:=Utl_Smtp.open_connection(mailhost);
    utl_smtp.helo(mail_conn, mailhost);
    utl_smtp.mail(mail_conn, pfrom);
    utl_smtp.rcpt(mail_conn, preceiver);
    utl_smtp.data(mail_conn, message);
    utl_smtp.quit(mail_conn);
    EXCEPTION WHEN OTHERS THEN
    dbms_output.put_line('error :'||SQLERRM||''||SQLCODE);
    END mis_test_send_mail ;
    Any help on this is highly appreciated.
    Regards,
    Cheriyan

    You need to include any headers that need to be shown in the mail in the message data. The headers section of the data needs to be separated from the body section by at least one blank line.
    message:= 'From: "sender name" <[email protected]>' || crlf;
    message:= message || 'To: "recipient" <[email protected]>' || crlf;
    message:= message || 'Subject: this is only a test' ||crlf;
    message:= message || crlf;
    message:= message || 'How Are You' ||crlf;The utl_smtp.mail and utl_smtp.rcpt procedures just tell the recieving SMTP server who is sending it and who to deliver it to, but what the recipient sees is what's in the headers section of the utl_smtp.data payload.
    You can take advantage of this in that you can include multiple calls to utl_smtp.rcpt, but not include them in the payload's header section. This is exactly what happens when you use your mail client to send blind carbon copies of an email.

  • Can't send e-mail using Mail.  Entourage works fine with same settings.

    I can't send e-mail using Mail. Using exactly the same settings on Entourage everything works fine.
    Until earlier today (for two days only) I couldn't send either. I was advised to run Keychain Access First Aid which spotted "Item “pop3.freezone.co.uk” is a duplicate; this item's port attribute is not set" and then repaired it (Freezone is the name of my ISP). Now I can send Mail but not receive.
    Even stranger is that until today I could receive Mail on one of my two accounts, while only Mail from one person got through on the other. Now no mail is arriving.
    I tried swapping the plist file for an older version from a backup of my system. That didn't work either.
    I'm tearing my hair out! Any suggestions?

    No.
    I'am sendig email from domain A using SMTP belonging to domain A.
    The emails that's addressis is the same as senders (@grader.ee) are going out. But all others don't.
    If there is wrong outgoing SMTP server even those emails can't send.

Maybe you are looking for

  • Pulling open invoices, and paid invoices with details (Query Help).

    Hello All, I am sure I messed something up in my joins. I am looking to pull a report of all invoices OINV for a month, then list details of any payment (if it is paid) next to it from RCT2. It is giving me a list of all of the paid invoices, but eve

  • External mass storage device doesn't appear in the finder

    When I plug either my camera or my iPhone into the USB port I get a message saying 'no camers was found' and the device doesn't appear in the finder. I can see the phone in iTunes and the camera in its own Canon software, but I can't access the devic

  • CRM BW Integration

    Hi, Can any one help me in knowing more about integration of CRM and BW... some basic steps? Cheers!!!!!!!

  • Software and pictures pixilated - is PSE12 not compatible with Mac retina display?

    Is there a software update that will fix this issue? My husband did not realise PSE12 wouldn't work with our Mac when he bought it for my Christmas. It doesn't say on the packaging or descriptions online. If anyone has an answer that would be very he

  • Updater error Creative Suite 5

    I've uninstalled/deactivated Creative Suite 5 (CS5) from a Win 7 Pro laptop and installed/activated it on a new Win 8.1 laptop. Programs in CS5 run and appear to be correctly activated (help menus only offer deactivation option). When I run the Updat