Failed to send mail

Hi,
Following is the exception that im getting when im sending the mail for the first time.
If i open my outlook and close it and if i try to send the mail, then im able to send the mail
How can i avoid this problem of opening the mailbox before sending the mail.
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
     com.sun.mail.smtp.SMTPAddressFailedException: 553 sorry, Authentication failed or timed out. Please do get messages first to authenticate yourself.(#4.4.3)
     at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
     at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
     at javax.mail.Transport.send0(Transport.java:169)
     at javax.mail.Transport.send(Transport.java:120)
     at SendMail.main(SendMail.java:37)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 553 sorry, Authentication failed or timed out. Please do get messages first to authenticate yourself.(#4.4.3)
     at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
     ... 4 more

How can i avoid this problem of opening the mailbox
before sending the mail.You probably can't, but you'll need to talk to the
administrator of your server to find out.
This is another instance of:
http://java.sun.com/products/javamail/FAQ.html#checkpop3first

Similar Messages

  • Notifications failed to send mail for journal approval with attachments

    Issue : Notifications failed to send mail for journals sent for approvals with attachments.
    Error :
    [WF_ERROR] ERROR_MESSAGE=3835: Error '-6502 - ORA-06502: PL/SQL: numeric or value error: character string buffer too small' encountered during execution of Generate function 'WF_XML.Generate' for event 'oracle.apps.wf.notification.send'. ERROR_STACK=
    WF_XML.GetAttachments(71009549, http://vfilvappclone.verifone.com:8000/pls/EBIZRPT, 13525)
    WF_XML.GenerateDoc(oracle.apps.wf.notification.send, 71009549)
    WF_XML.Generate(oracle.apps.wf.notification.send, 71009549)
    WF_XML.Generate(oracle.apps.wf.notification.send, 71009549)
    Wf_Event.setMessage(oracle.apps.wf.notification.send, 71009549, WF_XML.Generate)
    Wf_Event.dispatch_internal()
    Cause : Above error is thrown for Journals with attachment of file type Microsoft Office Excel Macro-Enabled Worksheet (.xlsm)
    Can anybody help with this?

    Please post the details of the application release, database version and OS.
    Please see if these docs help.
    ORA-20001 & ORA-06502 Workflow Errors [ID 761638.1]
    Manager Approval Notification Gives Error: Ora-O6502: Pl/Sql: Numeric Or Value Error: Character String Buffer Too Small [ID 352213.1]
    Approval Confirmation Email Is Not Received By Preparer - ERROR_MESSAGE=3835 ORA-20001 ORA-6502 [ID 465146.1]
    Notification Fails To Be Generated When A DOCX Document Is Attached [ID 1058183.1]
    Not Able To Send Multiple E-Mails Upon Approval Of Purchase Order [ID 333719.1]
    Expenses Workflow Error: "ORA-06502: PL/SQL: numeric or value error: associative array shape is not consistent with session parameters has been detected in fnd_global.put(CONC_LOGIN_ID,-1)" [ID 455882.1]
    Using Microsoft Office 2007 and 2010 with Oracle E-Business Suite 11i and R12 [ID 1077728.1] -- Notification Generation Fails
    ORA-06502 Buffer Too Small Error in Contracts Workflow Notification [ID 870712.1]
    Thanks,
    Hussein

  • Failed to send mail to external domain via portal

    Hi Gurus,
    By following the configuraion instructions in <b>SAP library - Collaboration - Groupware - Installing and Configuring E-Mail Connectivity</b>, I managed to send mail to recipients who reside in same domain e.g. <b>[email protected]</b> via portal.
    However, I failed to send mail to external domain e.g. <b>[email protected]</b>. I got the following error message:
    The mail could not be sent to the specified recipients com.sap.ip.collaboration.gw.impl.transport.javamail.exception.MailSendException: The mail could not be sent to the specified recipients
         at com.sap.ip.collaboration.gw.impl.transport.javamail.JavaMailTransport.sendMail(JavaMailTransport.java:183)
    --------- exception is chained. Original exception ------------
    javax.mail.SendFailedException: Invalid Addresses;
      nested exception is:
         javax.mail.SendFailedException: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
         at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:804)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:320)
    Please help.
    Thanks alot.

    Hi Ajey,
    Thanks for your reply. I had tried your suggestion but same problem occurred with same error output.
    Actually, I encounterred this error message before in my <b>Microsoft Outlook</b>, where System Admin returned me a mail saying that, my mail was undeliverable with the same error message. But this can be solved by applying the <b>Internet Email Account Setting - Outgoing Server - My outgoing server (SMTP) require authentication</b>.
    So I am wondering,
    1) This problem is caused by SMTP server?
    2) Is there any workaround (like the Outlook Setting) I can configure in Portal?
    Do you have any idea?
    Thanks,
    HauChee

  • Failed to send mail: java.lang.NullPointerException

    Hi @,
    I have configured my receiver mail adpter and while running it is throwing the following error in adapter engine and there is no trace availble to analyse the same Only the follwoing error :
    "failed to send mail: java.lang.NullPointerException"
    Any help Its urgent.
    Regards

    This is strange...some times this types of errors drives crazy isn't....delete it and recreate it.
    just curious the service for mail adapter  in Visaual admin is up right?

  • [nQSError: 75006] Failed to send MAIL Command

    Hello,
    We are on AIX and Siebel Analytics 7.8.5. We are having a weird issue with ibots. Wwe have around 800 ibots and only 65 of them fail with *[nQSError: 75006] Failed to send MAIL Command* this error. These ibots use to work good. I have created some test ibots and even those fail with the same error.
    Does any one have an idea..how to resolve this?
    Thanks in advance

    We are using Exchange Server. We are able to send e-mails to many usres....that means the credentials are correct. If we reschedule a delivered report..it is successful.
    Eventually succeeded, but encountered and resolved errors...
    Number of skipped recipients: 1 of 2
    +++ ThreadID: 8ca6 : 2010-09-23 09:30:37.000
    iBotID: /shared/_iBots/NBR - ED and Mktg/NBR Alert - Private Equipment
    [nQSError: 75006] Failed to send MAIL command.
    +++ ThreadID: 8ca6 : 2010-09-23 09:30:37.000
    iBotID: /shared/_iBots/NBR - ED and Mktg/NBR Alert - Private Equipment
    ...Trying SMTP Delivery loop again
    +++ ThreadID: 8ca6 : 2010-09-23 09:30:37.000
    ... Sleeping for 9 seconds.
    +++ThreadID: 8ca6 : 2010-09-23 09:30:46.000
    iBotID: /shared/_iBots/NBR - ED and Mktg/NBR Alert - Private Equipment
    [nQSError: 75006] Failed to send MAIL command.
    +++ ThreadID: 8ca6 : 2010-09-23 09:30:46.000
    iBotID: /shared/_iBots/NBR - ED and Mktg/NBR Alert - Private Equipment
    ...Trying SMTP Delivery loop again
    +++ ThreadID: 8ca6 : 2010-09-23 09:30:46.000
    ... Sleeping for 4 seconds.
    +++ ThreadID: 8ca6 : 2010-09-23 09:30:50.000
    iBotID: /shared/_iBots/NBR - ED and Mktg/NBR Alert - Private Equipment
    [nQSError: 75006] Failed to send MAIL command.
    Thanks

  • Transaction failed: Cannot send mail due to possible abuse

    For the past two days, I have not been able to send mail from one of my Verizon.net sub-accounts using Mozilla Thunderbird. However I can send mail from the Verizon Yahoo webmail website.
    I get this error message:
    An error occurred while sending mail. Transaction failed: Cannot send mail due to possible abuse; please visit http://postmaster.yahoo.com/abuse_smtp.html for more information.
    And when I click on "OK" in the message box, this second error message pops up:
    Sending of message failed. The message could not be sent because the connection to SMTP server outgoing.yahoo.verizon.net was lost in the middle of the transaction. Try again or contact your network administrator.
    When I go to http://postmaster.yahoo.com/abuse_smtp.html, there is just a generic Yahoo help page, with nothing specific about this problem.

    The possible abuse is likely a 24 hour hold for accounts suspected of sending Spam. Are you still having issues? Also what ports do you have the incoming/outgoing server set to?
    Anthony_VZ
    **If someones post has helped you, please acknowledge their assistance by clicking the red thumbs up button to give them Kudos. If you are the original poster and any response gave you your answer, please mark the post that had the answer as the solution**
    Notice: Content posted by Verizon employees is meant to be informational and does not supersede or change the Verizon Forums User Guidelines or Terms or Service, or your Customer Agreement Terms and Conditions or plan

  • Script task fails to send mail to GMAIL

    Hi   guys ,
       I am new here and i am glad i that i am here.  I am working in a company  as SQL Server developer(T-sql), i am learning SSIS because  i wanted to move to data warehousing.
    I not familiar and i don't know any thing about  C#,  but i am learning SSIS on my own.
    I tried to send mail to gmail  using script task , both sender and receiver with same mail ID using variables which i tried using tutorial i found from the below link.
    [quote]http://www.codeproject.com/Articles/85172/Send-Email-from-SSIS-with-option-to-indicate-Email[/quote]
    but finally when i execute the task , it returns failure message and email is not sent.
    [quote]SSIS package "Send mail using script task.dtsx" starting.
    Error: 0x8 at Script Task: The script returned a failure result.
    Task failed: Script Task
    SSIS package "Send mail using script task.dtsx" finished: Success.
    [/quote]
    Below message taken from progress tab
    [quote]Error: The script returned a failure result.[/quote]
    Can you all please help me in  finding where i am going wrong? please check below code which i have used in script task.
    Microsoft SQL Server Integration Services Script Task
    Write scripts using Microsoft Visual C# 2008.
    The ScriptMain is the entry point class of the script.
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using System.Text.RegularExpressions;
    using System.Net.Mail;
    namespace ST_9bc84810a62a401aa44ddd905bcd369d.csproj
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    #region VSTA generated code
    enum ScriptResults
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    #endregion
    The execution engine calls this method when the task executes.
    To access the object model, use the Dts property. Connections, variables, events,
    and logging features are available as members of the Dts property as shown in the following examples.
    To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
    To post a log entry, call Dts.Log("This is my log text", 999, null);
    To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
    To use the connections collection use something like the following:
    ConnectionManager cm = Dts.Connections.Add("OLEDB");
    cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
    Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
    To open Help, press F1.
    public void Main()
    string sSubject = "Test Subject";
    string sBody = "Test Message";
    int iPriority = 2;
    if (SendMail(sSubject, sBody, iPriority))
    Dts.TaskResult = (int)ScriptResults.Success;
    else
    //Fails the Task
    Dts.TaskResult = (int)ScriptResults.Failure;
    public bool SendMail(string sSubject, string sMessage, int iPriority)
    try
    string sEmailServer = Dts.Variables["sEmailServer"].Value.ToString();
    string sEmailPort = Dts.Variables["sEmailPort"].Value.ToString();
    string sEmailUser = Dts.Variables["sEmailUser"].Value.ToString();
    string sEmailPassword = Dts.Variables["sEmailPassword"].Value.ToString();
    string sEmailSendTo = Dts.Variables["sEmailSendTo"].Value.ToString();
    string sEmailSendCC = Dts.Variables["sEmailSendCC"].Value.ToString();
    string sEmailSendFrom = Dts.Variables["sEmailSendFrom"].Value.ToString();
    string sEmailSendFromName = Dts.Variables["sEmailSendFromName"].Value.ToString();
    SmtpClient smtpClient = new SmtpClient();
    MailMessage message = new MailMessage();
    MailAddress fromAddress = new MailAddress(sEmailSendFrom, sEmailSendFromName);
    //You can have multiple emails separated by ;
    string[] sEmailTo = Regex.Split(sEmailSendTo, ";");
    string[] sEmailCC = Regex.Split(sEmailSendCC, ";");
    int sEmailServerSMTP = int.Parse(sEmailPort);
    smtpClient.Host = sEmailServer;
    smtpClient.Port = sEmailServerSMTP;
    System.Net.NetworkCredential myCredentials =
    new System.Net.NetworkCredential(sEmailUser, sEmailPassword);
    smtpClient.Credentials = myCredentials;
    message.From = fromAddress;
    if (sEmailTo != null)
    for (int i = 0; i < sEmailTo.Length; ++i)
    if (sEmailTo[i] != null && sEmailTo[i] != "")
    message.To.Add(sEmailTo[i]);
    if (sEmailCC != null)
    for (int i = 0; i < sEmailCC.Length; ++i)
    if (sEmailCC[i] != null && sEmailCC[i] != "")
    message.To.Add(sEmailCC[i]);
    switch (iPriority)
    case 1:
    message.Priority = MailPriority.High;
    break;
    case 3:
    message.Priority = MailPriority.Low;
    break;
    default:
    message.Priority = MailPriority.Normal;
    break;
    //You can enable this for Attachments.
    //SingleFile is a string variable for the file path.
    //foreach (string SingleFile in myFiles)
    // Attachment myAttachment = new Attachment(SingleFile);
    // message.Attachments.Add(myAttachment);
    message.Subject = sSubject;
    message.IsBodyHtml = true;
    message.Body = sMessage;
    smtpClient.Send(message);
    return true;
    catch (Exception ex)
    return false;
    Please help me resolve this guys ... THANKS IN ADVANCE

    Thank you very much for your reply @Elvis Long,
    Sorry for the late reply
    Actually, i am not trying or executing this task  from my office , but i am trying this at my home :( .
    sEmailPort has value 587 sEmailServer has smtp.gmail.com
    Can you please check whether this C# coding is correct or not ? because finally it gives error saying "Script
    Task: The script returned a failure result" 
    so can you please check this with your system and let me know what is wrong with this code
    Thanks in advance  

  • Reporting Subscriptions Failing - "Failure Sending Mail". Must be something obvious!

    I've spent the last few hours on this and cannot for the life of me figure what it is that I have overlooked. I have created a report email subscription, nothing particularly fancy. It is always failing on:
    Failure sending mail: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
    The setup:
    SCCM 2012 R2
    SQL Server 2012 (on the SCCM server)
    Exchange 2010
    SCCM - Email Notification Component is configured correctly. The SMTP test works and I also receive alerts when one of my SCEP rules are triggered. All good.
    SQL Management Studio - DataBase  Mail is configured; sending a test e-mail works. Using Basic Authentication with a network account specified.
    Exchange 2010 has a Receiver Connector created to relay e-mails from the SCCM Server.
    Reporting Services Configuration Manager - Email Section has been completed.
    Can anyone point me in the right direction?

    Hi Garth,
    Thanks for the response. I was under the impression that CM12 uses SSRS (and thus the SQL Mail configuration) to send out the Subscription Reports, if that is definitely not the case I can eliminate that part from my configuration all together.
    So, to clarify:
    CM12 Alerts have always been working fine - no issue here and I understand this is a different kettle of fish to SSRS.
    <cite class="ipb" style="padding:0px 10px 8px;border-width:0px 2px 2px;border-left-style:solid;border-left-color:#989898;border-bottom-style:solid;border-bottom-color:#e5e5e5;border-right-style:solid;border-right-color:#e5e5e5;font-weight:bold;font-style:normal;overflow-x:auto;margin:-1px
    -12px 8px;width:1299px;display:block;-webkit-user-select:none;background:-webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(246, 246, 246)), to(rgb(229, 229, 229)));">Quote</cite>Why do you think that SSRS can send test message, where did you do this action?
    I actioned the "Send Test E-mail" option when you right-click on the Database Mail option within SQL2012. However, as you pointed out already, if this has absolutely
    nothing to do with the Subscription Reports configuration, then this is no longer relevant. If anything it just proves that e-mails can be sent via the Exchange server (using basic authentication).
    Now, I guess, I just need to figure what within SSRS Configuration Manager is missing, my trouble is that there isn't any detailed settings I can configure
    and Exchange logs doesn't indicate anything that isn't already reported by SCCM:
    2014-06-25T14:09:14.168Z,Exchange\SCCM01 - Subscription Reports Receiver,08D15B57A7508DA3,21,10.2.2.202:25,10.2.2.213:63905,>,530 5.7.1 Client was not authenticated,

  • Ios 8.0.2 multiple pop mail accounts fail to send mail

    When I set up my primary pop email account with a primary outgoing mail server and a second outgoing mail server as required by my email provider everything works fine. When sending a email and the primary outgoing server cant connect it searches and sends on the secondary. The problem is when the second pop email account is added, and the two outgoing servers are configured for that account, then neither account will search a secondary outgoing mail server if it cannot connect to the primary outgoing mail server.
    The only way to get the mail to send is to turn off the primary outgoing mail server in settings.
    This scenario worked just fine with 7.1.2 but not with any version of 8 that I have used. Apple botched email up and its not acceptable for people who use their phones for anything other than a toy!
    Please help if you can.

    First, reset the phone by holding the sleep and home button for about 10sec, until the Apple logo comes back again. You will not lose data by resetting, but it can cure some glitches after installing new software.
    If this does not work, set it up as new device, explained in this article:
    iOS: How to back up your data and set up your device as a new device
    If this does not work after restoring from the backup, try again, this time without using the backup, to make sure that this is not software related.

  • Failed to send E-Mail Alerts using Cisco NCS

    Hi,
    I was trying to configure the Email Alert Notication on Cisco NCS but it is not working.
    I SMTP server is configured and I add the server IP to NCS (Administration > Setting > Mail Server Configuration). When I click the Test button I always end up with the error message saying "Failed to send mail to primary SMTP server. Please make sure that you save mail configuration by hitting 'Save' button.". I tried saving it but I still end up with the same error. Did anybody encountered this on NCS?
    Regards,
    Leonard

    I have a slightly different issue.  We have an existing NCS box with the email account configured and it emails to one person.  When I add my name to the list of recipients, it only emails the first person in the list.  It seems to ignore the second person.
    Oddly enough, when I click on "test", it sends an email to the first person in the list, and that person can see in the email that I was copied on the email.  But my email never appears.  I even added my Yahoo! email account, and don't get it there either.
    Don't see anything in spam folders either.  Anyone know if there's a bug with adding more than one email address in NCS?

  • Cannot send mail from newsletter server and Server error: Unable to relay

    We have newsletter server. Sometimes we sent mail by our exchange 2010 server. But recently we are unable to send mail to external mail server. we sent mail by newsletter server within a domain now. We need to solve. Pls. check below log file and provide
    how to solve it.
    Sender ID: [email protected]
    our domain: www.silkways.net
    LOG:
    Status Msg : The email details entered successfully into the database.
    Status Msg : The email details entered successfully into the database.
    Access Level : 1
    MAIL SENT TO : [email protected]
    FAILED TO SEND MAIL TO : [email protected]
    Error : SMTP Error: The following recipients failed: [email protected]<p>SMTP server error: 5.7.1 Unable to relay
    </p>
     FAILED TO SEND MAIL TO : [email protected]
    Error : The following From address failed: [email protected]<p>SMTP server error: 5.5.2 Sender already specified
    </p>
    FAILED TO SEND MAIL TO : [email protected]
    Error : SMTP Error: The following recipients failed: [email protected]<p>SMTP server error: 5.7.1 Unable to relay
    </p>
     FAILED TO SEND MAIL TO : [email protected]
    Error : The following From address failed: [email protected]<p>SMTP server error: 5.5.2 Sender already specified
    </p>
     FAILED TO SEND MAIL TO : [email protected]
    Error : The following From address failed: [email protected]<p>SMTP server error: 4.7.0 Too many errors on this connection, closing transmission channel
    </p>
    FAILED TO SEND MAIL TO : [email protected]
    Error : SMTP Error: The following recipients failed: [email protected]<p>SMTP server error: 5.7.1 Unable to relay
    </p>
     FAILED TO SEND MAIL TO : [email protected]
    Error : The following From address failed: [email protected]<p>SMTP server error: 5.5.2 Sender already specified
    </p>

    Hi,
    Since you are able to send emails to internal domain i assume the application server IP address already allowed into Receive Connector.
    To relay application emails to external domain you should enable Externally Secured box in the Authentication Tab of the particular Receive Connector.
    Kottees :My Blog Please mark it as an answer if it really helps you.

  • Error compiling procedure send mail

    Hi all,
    I have this error message (on 10.2 version)
    Table or view doesn't exist
    At this line
    + select dd.directory_name into directory_name from dba_directories dd+
    + where dd.directory_path = line and rownum = 1;+
    But I don't know how can resolve it.
    This is the all procedure
    [http://forums.oracle.com/forums/]
    CREATE OR REPLACE PROCEDURE P_SPEDEMAIATTA ( from_name IN VARCHAR2,
    to_names IN VARCHAR2,
    subject     IN VARCHAR2,
    message     IN VARCHAR2 default null,
    html_message     IN VARCHAR2 default null,
    cc_names     IN VARCHAR2 default null,
    bcc_names     IN VARCHAR2 default null,
    filename1 varchar2 default null,
    filetype1 varchar2 default 'text/plain',
    filename2 varchar2 default null,
    filetype2 varchar2 default 'text/plain',
    filename3 varchar2 default null,
    filetype3 varchar2 default 'text/plain',
    V_CODIERRO OUT VARCHAR2,
    V_DESCERRO OUT VARCHAR2)
    is
    -- Change the SMTP host name and port number below to your own values,
    -- if not localhost on port 25:
    smtp_host varchar2(256) := 'SMTP.INET.IT';
    smtp_port number := 25;
    -- Change the boundary string, if needed, which demarcates boundaries of
    -- parts in a multi-part email, and should not appear inside the body of
    -- any part of the e-mail:
    boundary constant varchar2(256) := 'CES.Boundary.DACA587499938898';
    recipients varchar2(32767);
    directory_path varchar2(256);
    file_name varchar2(256);
    crlf varchar2(2):= chr(13) || chr(10);
    mesg varchar2(32767);
    conn UTL_SMTP.CONNECTION;
    type varchar2_table is table of varchar2(256) index by binary_integer;
    file_array varchar2_table;
    type_array varchar2_table;
    i binary_integer;
    my_code number;
    my_errm varchar2(32767);
    -- Function to return the next email address in the list of email addresses,
    -- separated by either a "," or a ";". From Oracle's demo_mail. The format
    -- of mailbox may be in one of these:
    -- someone@some-domain
    -- "Someone at some domain" &lt;someone@some-domain&gt;
    -- Someone at some domain &lt;someone@some-domain&gt;
    FUNCTION get_address(addr_list IN OUT VARCHAR2) RETURN VARCHAR2 IS
    addr VARCHAR2(256);
    i pls_integer;
    FUNCTION lookup_unquoted_char(str IN VARCHAR2,
    chrs IN VARCHAR2) RETURN pls_integer IS
    c VARCHAR2(5);
    i pls_integer;
    len pls_integer;
    inside_quote BOOLEAN;
    BEGIN
    inside_quote := false;
    i := 1;
    len := length(str);
    WHILE (i &lt;= len) LOOP
    c := substr(str, i, 1);
    IF (inside_quote) THEN
    IF (c = '"') THEN
    inside_quote := false;
    ELSIF (c = '\') THEN
    i := i + 1; -- Skip the quote character
    END IF;
    GOTO next_char;
    END IF;
    IF (c = '"') THEN
    inside_quote := true;
    GOTO next_char;
    END IF;
    IF (instr(chrs, c) &gt;= 1) THEN
    RETURN i;
    END IF;
    &lt;&lt;next_char&gt;&gt;
    i := i + 1;
    END LOOP;
    RETURN 0;
    END;
    BEGIN
    addr_list := ltrim(addr_list);
    i := lookup_unquoted_char(addr_list, ',;');
    IF (i &gt;= 1) THEN
    addr := substr(addr_list, 1, i - 1);
    addr_list := substr(addr_list, i + 1);
    ELSE
    addr := addr_list;
    addr_list := '';
    END IF;
    i := lookup_unquoted_char(addr, '&lt;'&gt;');
    IF (i &gt;= 1) THEN
    addr := substr(addr, 1, i - 1);
    END IF;
    END IF;
    i := lookup_unquoted_char(addr, '@');
    IF (i = 0 and smtp_host != 'localhost') THEN
    i := instr(smtp_host, '.', -1, 2);
    addr := addr || '@' || substr(smtp_host, i + 1);
    END IF;
    addr := '&lt;'&gt;';
    RETURN addr;
    END;
    -- Procedure to split a file pathname into its directory path and file name
    -- components.
    PROCEDURE split_path_name(file_path IN VARCHAR2, directory_path OUT VARCHAR2,
    file_name OUT VARCHAR2) IS
    pos number;
    begin
    -- Separate the filename from the directory name
    pos := instr(file_path,'/',-1);
    if pos = 0 then
    pos := instr(file_path,'\',-1);
    end if;
    if pos = 0 then
    directory_path := null;
    else
    directory_path := substr(file_path,1,pos - 1);
    end if;
    file_name := substr(file_path,pos + 1);
    end;
    -- Procedure to append a file's contents to the e-mail
    PROCEDURE append_file(directory_path IN VARCHAR2, file_name IN VARCHAR2,
    file_type IN VARCHAR2, conn IN OUT UTL_SMTP.CONNECTION) IS
    generated_name varchar2(30) := 'CESDIR' || to_char(sysdate,'HH24MISS');
    directory_name varchar2(30);
    file_handle utl_file.file_type;
    bfile_handle bfile;
    bfile_len number;
    pos number;
    read_bytes number;
    line varchar2(1000);
    data raw(200);
    my_code number;
    my_errm varchar2(32767);
    begin
    begin
    -- Grant access to the directory, unless already defined, and open
    -- the file (as a bfile for a binary file, otherwise as a text file).
    begin
    line := directory_path;
    select dd.directory_name into directory_name from dba_directories dd
    where dd.directory_path = line and rownum = 1;
    exception
    when no_data_found then
    directory_name := generated_name;
    end;
    if directory_name = generated_name then
    execute immediate 'create or replace directory ' || directory_name ||
    ' as ''' || directory_path || '''';
    execute immediate 'grant read on directory ' || directory_name ||
    ' to public';
    end if;
    if substr(file_type,1,4) != 'text' then
    bfile_handle := bfilename(directory_name,file_name);
    bfile_len := dbms_lob.getlength(bfile_handle);
    pos := 1;
    dbms_lob.open(bfile_handle,dbms_lob.lob_readonly);
    else
    file_handle := utl_file.fopen(directory_name,file_name,'r');
    end if;
    -- Append the file contents to the end of the message
    loop
    -- If it is a binary file, process it 57 bytes at a time,
    -- reading them in with a LOB read, encoding them in BASE64,
    -- and writing out the encoded binary string as raw data
    if substr(file_type,1,4) != 'text' then
    if pos + 57 - 1 &gt; bfile_len then
    read_bytes := bfile_len - pos + 1;
    else
    read_bytes := 57;
    end if;
    dbms_lob.read(bfile_handle,read_bytes,pos,data);
    utl_smtp.write_raw_data(conn,utl_encode.base64_encode(data));
    pos := pos + 57;
    if pos &gt; bfile_len then
    exit;
    end if;
    -- If it is a text file, get the next line of text, append a
    -- carriage return / line feed to it, and write it out
    else
    utl_file.get_line(file_handle,line);
    utl_smtp.write_data(conn,line || crlf);
    end if;
    end loop;
    -- Output any errors, except at end when no more data is found
    exception
    when no_data_found then
    null;
    when others then
    my_code := SQLCODE;
    my_errm := SQLERRM;
    dbms_output.put_line('Error code ' || my_code || ': ' ||
    my_errm);
    end;
    -- Close the file (binary or text)
    if substr(file_type,1,4) != 'text' then
    dbms_lob.close(bfile_handle);
    else
    utl_file.fclose(file_handle);
    end if;
    if directory_name = generated_name then
    execute immediate 'drop directory ' || directory_name;
    end if;
    end;
    begin
    -- Load the three filenames and file (mime) types into an array for
    -- easier handling later
    file_array(1) := filename1;
    file_array(2) := filename2;
    file_array(3) := filename3;
    type_array(1) := filetype1;
    type_array(2) := filetype2;
    type_array(3) := filetype3;
    -- Open the SMTP connection and set the From and To e-mail addresses
    conn := utl_smtp.open_connection(smtp_host,smtp_port);
    utl_smtp.helo(conn,smtp_host);
    recipients := from_name;
    utl_smtp.mail(conn,get_address(recipients));
    recipients := to_names;
    while recipients is not null loop
    utl_smtp.rcpt(conn,get_address(recipients));
    end loop;
    recipients := cc_names;
    while recipients is not null loop
    utl_smtp.rcpt(conn,get_address(recipients));
    end loop;
    recipients := bcc_names;
    while recipients is not null loop
    utl_smtp.rcpt(conn,get_address(recipients));
    end loop;
    utl_smtp.open_data(conn);
    -- Build the start of the mail message
    mesg := 'Date: ' || TO_CHAR(SYSDATE,'dd Mon yy hh24:mi:ss') || crlf ||
    'From: ' || from_name || crlf ||
    'Subject: ' || subject || crlf ||
    'To: ' || to_names || crlf;
    if cc_names is not null then
    mesg := mesg || 'Cc: ' || cc_names || crlf;
    end if;
    if bcc_names is not null then
    mesg := mesg || 'Bcc: ' || bcc_names || crlf;
    end if;
    mesg := mesg || 'Mime-Version: 1.0' || crlf ||
    'Content-Type: multipart/mixed; boundary="' || boundary || '"' ||
    crlf || crlf ||
    'This is a Mime message, which your current mail reader may not' || crlf ||
    'understand. Parts of the message will appear as text. If the remainder' || crlf ||
    'appears as random characters in the message body, instead of as' || crlf ||
    'attachments, then you''ll have to extract these parts and decode them' || crlf ||
    'manually.' || crlf || crlf;
    utl_smtp.write_data(conn,mesg);
    -- Write the text message or message file, if any
    if message is not null then
    mesg := '--' || boundary || crlf ||
    'Content-Type: text/plain; name="message.txt"; charset=US-ASCII' ||
    crlf ||
    'Content-Disposition: inline; filename="message.txt"' || crlf ||
    'Content-Transfer-Encoding: 7bit' || crlf || crlf;
    utl_smtp.write_data(conn,mesg);
    if instr(message,'/') = 1 or instr(message,':\') = 2 or
    instr(message,'\\') = 1 then
    split_path_name(message,directory_path,file_name);
    append_file(directory_path,file_name,'text',conn);
    utl_smtp.write_data(conn,crlf);
    else
    utl_smtp.write_data(conn,message || crlf);
    end if;
    end if;
    -- Write the HTML message or message file, if any
    if html_message is not null then
    mesg := '--' || boundary || crlf ||
    'Content-Type: text/html; name="message.html"; charset=US-ASCII' ||
    crlf ||
    'Content-Disposition: inline; filename="message.html"' || crlf ||
    'Content-Transfer-Encoding: 7bit' || crlf || crlf;
    utl_smtp.write_data(conn,mesg);
    if instr(html_message,'/') = 1 or instr(html_message,':\') = 2 or
    instr(html_message,'\\') = 1 then
    split_path_name(html_message,directory_path,file_name);
    append_file(directory_path,file_name,'text',conn);
    utl_smtp.write_data(conn,crlf);
    else
    utl_smtp.write_data(conn,html_message || crlf);
    end if;
    end if;
    -- Append the files
    for i in 1..3 loop
    -- If the filename has been supplied ...
    if file_array(i) is not null then
    split_path_name(file_array(i),directory_path,file_name);
    -- Generate the MIME boundary line according to the file (mime) type
    -- specified.
    mesg := crlf || '--' || boundary || crlf;
    if substr(type_array(i),1,4) != 'text' then
    mesg := mesg || 'Content-Type: ' || type_array(i) ||
    '; name="' || file_name || '"' || crlf ||
    'Content-Disposition: attachment; filename="' ||
    file_name || '"' || crlf ||
    'Content-Transfer-Encoding: base64' || crlf || crlf ;
    else
    mesg := mesg || 'Content-Type: application/octet-stream; name="' ||
    file_name || '"' || crlf ||
    'Content-Disposition: attachment; filename="' ||
    file_name || '"' || crlf ||
    'Content-Transfer-Encoding: 7bit' || crlf || crlf ;
    end if;
    utl_smtp.write_data(conn,mesg);
    -- Append the file contents to the end of the message
    append_file(directory_path,file_name,type_array(i),conn);
    utl_smtp.write_data(conn,crlf);
    end if;
    end loop;
    -- Append the final boundary line
    mesg := crlf || '--' || boundary || '--' || crlf;
    utl_smtp.write_data(conn,mesg);
    -- Close the SMTP connection
    utl_smtp.close_data(conn);
    utl_smtp.quit(conn);
    exception
    when utl_smtp.transient_error or utl_smtp.permanent_error then
    my_code := SQLCODE;
    my_errm := SQLERRM;
    V_CODIERRO := SQLCODE;
    V_DESCERRO := SQLERRM;
    begin
    utl_smtp.quit(conn);
    exception
    when utl_smtp.transient_error or utl_smtp.permanent_error then
    null;
    end;
    -- raise_application_error(-20000,
    -- 'Failed to send mail - SMTP server down or unavailable: Error code ' ||
    -- my_code || ': ' || my_errm);
    when others then
    my_code := SQLCODE;
    my_errm := SQLERRM;
    V_CODIERRO := SQLCODE;
    V_DESCERRO := SQLERRM;
    raise_application_error(-20000,
    'Failed to send mail: Error code ' || my_code || ': ' || my_errm);
    end;
    Edited by: mosquito70 on Jan 22, 2009 12:33 PM

    Thank's,
    but the problem is that I have the system user password but I haven't that of sys.
    So, if I try to run the statment
    grant select on dba_directories to myuser;
    I have the this code error ORA-01031
    How can resolve, without use all_directories?
    Thank's
    Bye

  • Sending Mails to Multiple Recipients using UTL_SMTP

    create or replace procedure send_mail(msg_text varchar2) is
    c utl_smtp.connection;
    PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
    BEGIN
    utl_smtp.write_data(c, name || ': ' || header || utl_tcp.CRLF);
    END;
    BEGIN
    c := utl_smtp.open_connection('outlook.abc.com');
    utl_smtp.helo(c, 'abc.com');
    utl_smtp.mail(c, '[email protected]');
    utl_smtp.rcpt(c, '[email protected]');
    utl_smtp.open_data(c);
    send_header('From', '"root" <[email protected]>');
    send_header('To', '"abc" <[email protected]>');
    send_header('Subject', 'WARNING: Salary has been changed');
    utl_smtp.write_data(c, utl_tcp.CRLF || msg_text);
    utl_smtp.close_data(c);
    utl_smtp.quit(c);
    EXCEPTION
    WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
    BEGIN
    utl_smtp.quit(c);
    EXCEPTION
    WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
    NULL; -- When the SMTP server is down or unavailable, we don't have
    -- a connection to the server. The quit call will raise an
    -- exception that we can ignore.
    END;
    raise_application_error(-20000,
    'Failed to send mail due to the following error: ' || sqlerrm);
    END;
    ==============
    when I execute the above using
    sql> exec send_mail('hihihih');
    I am getting the mails..no problems...
    So..I created the following trigger and used the above procedure to send the mail...
    CREATE OR REPLACE TRIGGER test_emp_table_trg
    AFTER UPDATE
    ON test_emp_table
    FOR EACH ROW
    WHEN (NEW.sal <> OLD.sal)
    DECLARE
    l_employee_name VARCHAR2 (240);
    l_old_sal VARCHAR2 (240);
    l_new_sal VARCHAR2 (240);
    l_message VARCHAR2 (240);
    BEGIN
    /* Gets the employee full name */
    BEGIN
    SELECT ename
    INTO l_employee_name
    FROM test_emp_table
    WHERE empno = :OLD.empno;
    EXCEPTION
    WHEN OTHERS
    THEN
    l_employee_name := NULL;
    END;
    /* Gets the old Salary */
    BEGIN
    SELECT sal
    INTO l_old_sal
    FROM test_emp_table
    WHERE empno = :OLD.empno;
    EXCEPTION
    WHEN OTHERS
    THEN
    l_old_sal := 0;
    END;
    /* Gets the new salary */
    BEGIN
    SELECT sal
    INTO l_new_sal
    FROM test_emp_table
    WHERE empno= :NEW.empno;
    EXCEPTION
    WHEN OTHERS
    THEN
    l_new_sal := 0;
    END;
    l_message:=
    'Employee Name= '
    || l_employee_name
    || 'Old Salary= '
    || l_old_sal
    || 'New Salary= '
    || l_new_sal;
    BEGIN
    send_mail (l_message);
    END;
    END;
    ===================
    I am not getting desired output..what might be problem friends...I am getting 0 values for old salary and new salary......
    One more thing..when i use 2 receipts in the send_mail procedure like this...I added the following lines in the procedure to send to multiple receipents..
    ======
    utl_smtp.rcpt(c, '[email protected]');
    utl_smtp.rcpt(c, '[email protected]');
    =============
    Pleas have a look and correct me, where i went wrong....
    Edited by: oraDBA2 on Sep 22, 2008 3:12 PM

    Hi, You can use the following routine to send mail to multiple recipients through utl_smtp.
    create or replace package mail_pkg
    as
    type array is table of varchar2(255);
    procedure send( p_sender_e_mail in varchar2,
    p_from in varchar2,
    p_to in array default array(),
    p_cc in array default array(),
    p_bcc in array default array(),
    p_subject in varchar2,
    p_body in long );
    end;
    create or replace package body mail_pkg
    begin
    g_crlf char(2) default chr(13)||chr(10);
    g_mail_conn utl_smtp.connection;
    g_mailhost varchar2(255) := 'ur mail server';
    function address_email( p_string in varchar2,
    p_recipients in array ) return varchar2
    is
    l_recipients long;
    begin
    for i in 1 .. p_recipients.count
    loop
    utl_smtp.rcpt(g_mail_conn, p_recipients(i));
    if ( l_recipients is null )
    then
    l_recipients := p_string || p_recipients(i) ;
    else
    l_recipients := l_recipients || ', ' || p_recipients(i);
    end if;
    end loop;
    return l_recipients;
    end;
    procedure send( p_sender_e_mail in varchar2,
    p_from in varchar2,
    p_to in array default array(),
    p_cc in array default array(),
    p_bcc in array default array(),
    p_subject in varchar2,
    p_body in long );
    end;
    is
    l_to_list long;
    l_cc_list long;
    l_bcc_list long;
    l_date varchar2(255) default
    to_char( SYSDATE, 'dd Mon yy hh24:mi:ss' );
    procedure writeData( p_text in varchar2 )
    as
    begin
    if ( p_text is not null )
    then
    utl_smtp.write_data( g_mail_conn, p_text || g_crlf );
    end if;
    end;
    begin
    g_mail_conn := utl_smtp.open_connection(g_mailhost, 25);
    utl_smtp.helo(g_mail_conn, g_mailhost);
    utl_smtp.mail(g_mail_conn, p_sender_e_mail);
    l_to_list := address_email( 'To: ', p_to );
    l_cc_list := address_email( 'Cc: ', p_cc );
    l_bcc_list := address_email( 'Bcc: ', p_bcc );
    utl_smtp.open_data(g_mail_conn );
    writeData( 'Date: ' || l_date );
    writeData( 'From: ' || nvl( p_from, p_sender_e_mail ) );
    writeData( 'Subject: ' || nvl( p_subject, '(no subject)' ) );
    writeData( l_to_list );
    writeData( l_cc_list );
    utl_smtp.write_data( g_mail_conn, '' || g_crlf );
    utl_smtp.write_data(g_mail_conn, p_body );
    utl_smtp.close_data(g_mail_conn );
    utl_smtp.quit(g_mail_conn);
    end;
    end;
    begin
    mail_pkg.send
    (p_sender_e_mail => 'urmail',
    p_from => 'urmail',
    p_to => mail_pkg.array( 'urmail','othersmail' ),
    p_cc => mail_pkg.array( ' othermail ' ),
    p_bcc => mail_pkg.array( '' ),
    p_subject => 'This is a subject',
    p_body => 'Hello Buddy, this is the mail you need' );
    end;
    /

  • Why i can't send "MAIL FROM:"?

    i wonder why i failed to send "MAIL FROM:" while commnunicating with the server using SMTP protocol?
    my code is:
    socket = new java.net.Socket(strServer, 25);
    dis = new java.io.DataInputStream(socket.getInputStream());
    dos = new java.io.DataOutputStream(socket.getOutputStream());
    //send Mail from command to the server
    dos.writeBytes("MAIL FROM: " + "[email protected]" + "\r\n");
    response = readLastLine(dis); //get the last line of the reply
    if (!response.startsWith("250")) { //if ok, response should starts with
    //250, otherwise, wrong
    destroyResource(socket, dis, dos);
    return;
    when i debug the program, i found the response starts with "500"
    i don't know why?
    can somebody give me the answer?

    Wouldn't it be easier to just use the JavaMail API rather than
    writing your own SMTP protocol support?
    What message does the server include with its response?

  • Oracle PLSQL Send mail Issue.

    Hi All,
    I used to send some emails using oracle PLSQL code in both 10 g and 11g.But now days mail is getting triggered without any body in both the 10g and 11g versions.
    Some mails are triggering perfectly.I am unable to sort out the issue, please help me in this concern.

    Code that i have used is:
    create or replace
    PROCEDURE Sendmail(V_MAILHOST VARCHAR2,V_FROM VARCHAR2,V_TO clob ,V_CC VARCHAR2, V_SUBJECT VARCHAR2,V_MSGTEXT VARCHAR2,V_MODULE VARCHAR2) AS
      l_mail_conn   UTL_SMTP.connection;
      l_subject      VARCHAR2(100):='test mail';
      l_msg_text   VARCHAR2(500):='hi , testing alert mail';
      v_reply      utl_smtp.reply;
      L_RECIPIENTS  clob;
      l_recipients1  clob;
      V_TO1            clob;
      v_errmsg        VARCHAR2(500);
      mul_recip        NUMBER;
      mul_recip1        NUMBER;
      slen             NUMBER:=1;
      slen1             NUMBER:=1;
      V_errcode        VARCHAR2(500);
    BEGIN
      l_mail_conn:= UTL_SMTP.open_connection(v_mailhost,25);
       v_reply :=UTL_SMTP.helo(l_mail_conn, v_mailhost);
       v_reply :=UTL_SMTP.mail(l_mail_conn, v_from);
      -- V_TO1:=null;--'[email protected]';
       SELECT INSTR(V_TO,',') INTO mul_recip FROM dual;
        IF mul_recip =0
        THEN
             utl_smtp.rcpt(l_mail_conn, V_TO );
        ELSE
            WHILE(INSTR(V_TO,',',slen) > 0)
            LOOP
                  l_recipients := SUBSTR(V_TO, slen, INSTR(SUBSTR(V_TO,slen),',')-1);
                  slen := slen+INSTR(SUBSTR(V_TO, slen),',');
                utl_smtp.rcpt(l_mail_conn, l_recipients);
            END LOOP;
                l_recipients := SUBSTR(V_TO, slen);
                utl_smtp.rcpt(l_mail_conn, l_recipients);
        END IF;    
         IF V_CC IS NOT NULL
         THEN
          SELECT INSTR(V_CC,',') INTO mul_recip1 FROM dual;
        IF mul_recip1 =0
        THEN
             utl_smtp.rcpt(l_mail_conn, V_CC );
        ELSE
            WHILE(INSTR(V_CC,',',slen1) > 0)
            LOOP
                  l_recipients1 := SUBSTR(V_CC, slen1, INSTR(SUBSTR(V_CC,slen1),',')-1);
                  slen1 := slen1+INSTR(SUBSTR(V_CC, slen1),',');
                utl_smtp.rcpt(l_mail_conn, l_recipients1);
            END LOOP;
                l_recipients1 := SUBSTR(V_CC, slen1);
                utl_smtp.rcpt(l_mail_conn, l_recipients1);
        END IF;    
    END IF;        
    v_reply :=utl_smtp.open_data(l_mail_conn );
    utl_smtp.write_data(l_mail_conn, 'From: ' || V_FROM || utl_tcp.crlf);
    utl_smtp.write_data(l_mail_conn, 'Subject: ' || v_subject || utl_tcp.crlf);
    utl_smtp.write_data(l_mail_conn, 'To: ' || V_TO || utl_tcp.crlf);
    utl_smtp.write_data(l_mail_conn, 'CC: ' || V_CC || utl_tcp.crlf);
    utl_smtp.write_data(l_mail_conn, 'Content-Type: text/html' || utl_tcp.crlf);
    UTL_SMTP.WRITE_DATA(L_MAIL_CONN, V_MSGTEXT );
      if length(V_TO)>=4000 then
      dbms_output.put_line('none');
      else
       insert into MAIL_LOG(MAILFROM, MAILTO, SUBJECT, LOGGED_DATE, MAIL_STATUS, MAILCC, MAILTEXT,MODULE_ID)
          VALUES(V_FROM,v_to,V_SUBJECT,SYSDATE,'sent',V_CC,V_MSGTEXT,V_MODULE);
        end if;
        utl_smtp.close_data(l_mail_conn );
        utl_smtp.quit(l_mail_conn);
    EXCEPTION
    WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
        BEGIN
          UTL_SMTP.QUIT(l_mail_conn);
        EXCEPTION
          WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN
            NULL; -- When the SMTP server is down or unavailable, we don't have
                  -- a connection to the server. The QUIT call will raise an
                  -- exception that we can ignore.
        END;
         v_errmsg:='Failed to send mail due to the following error: ' ||SQLERRM||' errcode '||SQLCODE||'from :'||V_FROM|| ' V_TO '||V_TO;
    INSERT INTO MAIL_LOG(MAILFROM, MAILTO, SUBJECT, LOGGED_DATE, MAIL_STATUS, MAILCC, MAILTEXT,MODULE_ID)
    VALUES(V_FROM,v_to,V_SUBJECT,SYSDATE,v_errmsg,V_CC,V_MSGTEXT,V_MODULE);
    END Sendmail;

Maybe you are looking for

  • How to include 3 sql statements in a single procedure

    I have 3 SQL statements to create 3 tables: Table1:To get all the data from an ORIGIN table that have an expiration_dates between 02/01/2006 and 04/30/2006. This has all the customer data (customer_id, company, etc…) Table 2:Secondly I am getting all

  • Unable to check all apps to synch manually in itunes

    When I manually synch apps with my ipod touch a check does not always apear in the check box in itunes, but I will see the app pop onto the ipod 'screen' shown in itunes. It gets confusing as to whether or not an app is going to be installed or remov

  • PO part no and SKU part number different

    I have the Material part no on which we want to do Procurement. and put the material in stock and do valuation. Then I have the Vendors part number which is different than above part no. Mans if my material code is ABC then Vendors code may be DFG. I

  • Keynote 08 color problem

    I have a macbook pro and installed keynote 08 on it and have the following peculiar problem. When I try to change the color of a graphic/text object, using the color pellete, the pellete (and also the color rectangle in the inspector window) show the

  • TS4124 How do i cancel my imatch acount?

    I want to change my country in my iTunes account. But it keeps telling me that i need to cancel my imatch account, how can i do that?