Month: December 2015

Using GMail SMTP in AEM 6.0

smtp

If you are trying to use Gmail SMTP in AEM 6.0 or any Java based Mail Client and see above error logs.. authentication failed…not able to connect to smtp.gmail.com etc please make sure 2 things are done at your client machine where you are testing. i spend 4 to 5 hours to find the solution.

  1. Disable the firewall on your laptop or PC.
  2. Use following screenshot for SMTP configuration.

smtp1

Sample code here.

List<InternetAddress> emailRecipients = new ArrayList<InternetAddress>();
try {

@Reference
private MessageGatewayService messageGatewayService;
@Reference
private MessageGateway<HtmlEmail> messageGateway;
HtmlEmail email = new HtmlEmail();
emailRecipients.add(new InternetAddress(userName));
email.setTo(emailRecipients);
email.setSubject(“XXX Password Reset”);

StringBuffer sb = new StringBuffer();

sb.append(“<b>XXX Password Reset</b> <BR> To: “+userName);
sb.append(content);

email.setHtmlMsg(sb.toString());
messageGateway = messageGatewayService.getGateway(HtmlEmail.class);
messageGateway.send(email);
} catch (Exception ex) {
ex.printStackTrace();
LOGGER.debug(” Exception caught in send email” + ex.getMessage());

return false;
}

 

 

Advertisement

User authentication using AngularJS, PHP, MySQL

I appreciate Swadesh Behera for contributing so much to Web Community who provides several  demo application on Angular JS, PHP and mySQL.

Particularly http://www.angularcode.com/user-authentication-using-angularjs-php-mysql/ is great.

I did setup on my local windows 2007 Laptop with PHP Separate distribution using Windows Apache 2.4.

People have consistently faced problem when they are running the Demo application in their local env.

session, signup and login HTTP Get and Post services consistently failed with 404 error.

I faced too and understood that issue would be primarily by doing two things.

  1. .htaccess
  2. httpd.conf allowing URL so 404 error could be resolved.

Steps i did to fix the issue.

  1. .htaccess

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]

  2. httpd.conf.. Allowoveride ALL has to be done to fix 404 error.
    <Directory “Z:/Projects/xyz/Apache24/htdocs”>
    #
    # Possible values for the Options directive are “None”, “All”,
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that “MultiViews” must be named *explicitly* — “Options All”
    # doesn’t give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be “All”, “None”, or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #

        AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
    </Directory>