首页 \ 问答 \ 发送邮件的问题?(Issue to send mail?)

发送邮件的问题?(Issue to send mail?)

我在java Spring中创建了邮件发送应用程序,邮件发送在本地服务器上正常工作。 我导出(战争文件)和主机进入tomcat服务器然后执行应用程序但邮件没有发送我不知道下面的代码是什么问题?

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMail {
    public static void main(String[] args) {
        Properties props = new Properties();
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.socketFactory.port", "465");
        props.put("mail.smtp.socketFactory.class",
                "javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "465");

        Session session = Session.getDefaultInstance(props,
        new javax.mail.Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication("username","password");
                }
            });

        try {

            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress("----@gmail.com"));
            message.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse("----@gmail.com"));
            message.setSubject("Test");
            message.setText("Hello"); 
            Transport.send(message); 
            System.out.println("Done"); 
        } catch (MessagingException e) {
            throw new RuntimeException(e);
        }
    }
}

i created the application for mail sending in java Spring, the mail sending properly working in local server. after i export the (war file ) and host into tomcat server then execute the app but mail was not sending i don't know what is the problem of following code?

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMail {
    public static void main(String[] args) {
        Properties props = new Properties();
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.socketFactory.port", "465");
        props.put("mail.smtp.socketFactory.class",
                "javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "465");

        Session session = Session.getDefaultInstance(props,
        new javax.mail.Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication("username","password");
                }
            });

        try {

            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress("----@gmail.com"));
            message.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse("----@gmail.com"));
            message.setSubject("Test");
            message.setText("Hello"); 
            Transport.send(message); 
            System.out.println("Done"); 
        } catch (MessagingException e) {
            throw new RuntimeException(e);
        }
    }
}

原文:https://stackoverflow.com/questions/25809460
更新时间:2022-09-08 08:09

最满意答案

SELECT Name
FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%TableNameOrWhatever%'

BTW - 这是一个方便的资源,这种类型的问题: http : //msdn.microsoft.com/en-us/library/ms345522%28v=SQL.90%29.aspx


SELECT Name
FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%TableNameOrWhatever%'

BTW -- here is a handy resource for this type of question: Querying the SQL Server System Catalog FAQ

相关问答

更多
  • SELECT Name FROM sys.procedures WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%TableNameOrWhatever%' BTW - 这是一个方便的资源,这种类型的问题: http : //msdn.microsoft.com/en-us/library/ms345522%28v=SQL.90%29.aspx SELECT Name FROM sys.procedures WHERE OBJECT_DEFINITION(OBJECT_I ...
  • 如果你可能希望将这段代码的结果与其他表相结合,那么显然一个表值函数可以让你在一个SELECT语句中组合结果。 一般来说,有一个层次结构(View
  • 我做一些非常类似于你的事情。 我通常会包含一个默认为false的DEBUG参数,我可以在运行时设置为true。 然后将调试语句包装到“If DEBUG”块中。 我还使用一个记录表,我的许多工作,以便我可以审查流程和时间。 我的调试代码也在那里输出。 我包括调用参数名称,简要描述,受影响的行数(如果适用),注释字段和时间戳。 良好的调试工具是所有SQL平台的令人遗憾的失败之一。 I do something very similar to you. I'll usually include a DEBUG p ...
  • 在MySQL中,存储过程中的查询与直接从Java(或其他)程序发出的相同查询之间的性能差异非常小。 (RDMS服务器的其他一些产品编译它们的存储过程,因此可以从它们中获得一些优化。但是MySQL很简单。) 您可以将查询移动到存储过程而无需担心性能。 In MySQL there is very little performance difference between queries in stored procedures and the same queries issued directly from ...
  • 根据MSDN ,ERROR_MESSAGE()等仅在TRY ... CATCH语句的CATCH块内设置。 According to MSDN, ERROR_MESSAGE() etc are only set within the CATCH block of a TRY ... CATCH statement.
  • 存储过程会将复杂的逻辑移动到系统的数据库部分,因此您可以通过避免PHP发出大量插入来有效地利用工作(可能很多)。 如果您将服务器脚本端的内容移植到存储过程,则可能会提高性能。 对于第二个问题,您应该从mysql API迁移到mysqli API,因为mysql API 已被弃用 。 Stored procedures would move the complicated logic to the database part of your system, so you would effectively l ...
  • 不要依赖于INFORMATION_SCHEMA.ROUTINES,因为ROUTINE_DEFINITION只是nvarchar(4000) 。 你需要sys.sql_modules ,其中definition是nvarchar(max) 尝试以下任何一种方式以找到需要修改的过程: SELECT DISTINCT LEFT(s.name+'.'+o.name, 100) AS Object_Name,o.type_desc --, m.definition FROM sys.sql_modul ...
  • 在他们的身体中具有文本'thetable'的函数。 查询返回包含'thetable'的函数名称,行号和行: select * from ( select proname, row_number() over (partition by proname) as line, textline from ( select proname, unnest(string_to_array(prosrc, chr(10))) textline from pg_proc p ...
  • 我只是玩这个,而不是愤怒地使用它,但liquibase看起来效果很好。 I've only played with this, rather than used it in anger, but liquibase appears to work quite well.
  • 基于@Kev回答,您可以批量插入到临时表中,然后可以触发存储过程。 我假设你对另一个表有一个FK约束,所以在插入目标表之前你需要这个值。 如果可能,您可以尝试删除约束。 然后执行批量插入,然后触发器可以稍后更新列。 Based on @Kev answer, you can do the bulk insert into a staging table and then you can have a trigger kick off your stored procedure. I'm assuming y ...

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)