Error sending e-mail using Gmail SMTP

你离开我真会死。 提交于 2019-12-02 04:54:51

I used this & it worked in java PHP prop as well you can set the same way.

    String to = "shafi0907@gmail.com";
    //change accordingly

    //Get the session object

    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("shafi0907@gmail.com", "<your password");//change accordingly
        }
    });

I replaced

$mail->Host = "ssl://smtp.gmail.com:465";

with just

$mail->Host ="smtp.gmail.com:465";

and it worked !!!

Thanks everybody.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!