Wednesday, December 18, 2019

Sending website contact form email using Laravel + AWS SES

Sending mail from a web contact form using the AWS SES. 
First, we need to install a composer package called aws/aws-sdk-php and follow its instructions.

on Custom settings from config/services.php
AWS_SES_REGION=ap-southeast-2

Example: 
MAIL_MAILER=ses
#MAIL_MAILER=smtp
#MAIL_HOST=smtp.mailtrap.io
#MAIL_PORT=2525
#MAIL_USERNAME=84ba092b676750b44681
#MAIL_PASSWORD=04477ca9c6767f44406f
#MAIL_ENCRYPTION=TLS
# Global settings
MAIL_FROM_ADDRESS=info@microtechna.com
MAIL_FROM_NAME="${APP_NAME}"
# Custom settings from config/services.php
AWS_SES_REGION=ap-southeast-2

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
#AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=


On the other side, we need to Create User for SMTP(it also a IAM user) from SES dashboard. Credentials for SMTP users are only available when creating the user. For your protection, you should never share your SMTP credentials with anyone.

For example,
ses-smtp-user.20***2-900
SMTP Username: AKI*******W
SMTP Password: BJT*********51M
Secondly, we need to create a IAM user with the AmazonSESFullAccess policy we may named it "arn:aws:iam::2****80:user/ses-smtp-user.website-form-email".

For example,
arn:aws:iam::25*****80:user/ses-smtp-user.website-form-email





Accesskey:
ID: A****************Z
Secret: hT*****bqQ***************BB3



You need to put the values in your .env file on laravel. also varify the sender/receiver email to work with the sandbox or apply for increase the SES email sending limit.

MAIL_DRIVER=ses
MAIL_HOST=email-smtp.ap-southeast-2.amazonaws.com
MAIL_PORT=465
MAIL_USERNAME=AKI*******W (SMTP Username)
MAIL_PASSWORD=BJT*********51M (SMTP Password)
MAIL_ENCRYPTION=TLS

SES_KEY=AKI*******W (SMTP Username)
SES_KEY_SECRET=BJT*********51M (SMTP Password)
SES_REGION=ap-southeast-2

AWS_ACCESS_KEY_ID=A******Z
AWS_SECRET_ACCESS_KEY=h*****BB3
AWS_DEFAULT_REGION=ap-southeast-2
AWS_BUCKET=


Normally:
We can set the env like for general web hosting provider.
backup code:
MAIL_DRIVER=smtp
MAIL_HOST=webcloud02.iad01.ds.network
MAIL_PORT=465
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=SSL






Good luck!



Monday, November 25, 2019

Creating a eclips project.

Download the jdbc connector from mysql website.

Copy to project folder and set the CLASSPATH.


Source codes:
mysql> SHOW DATABASES;

mysql> CREATE DATABASE employees;

mysql> USE employees;


CREATE TABLE IF NOT EXISTS emp (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    age TINYINT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)  ENGINE=INNODB;


mysql> SELECT * FROM emp;

mysql> DESCRIBE emp;

mysql> SHOW TABLES;

mysql> INSERT INTO emp(name, age) VALUES('Fahad', 18);

mysql> exit


Java Source Code:
https://bdjunayed.visualstudio.com/SampleJFrameExample

Friday, November 22, 2019

MySQL connection with Jdbc Java 12 - 13 and insert in to table

First download the driver, then make a tables and download the xammp for the mysql server 5.7.

Video links:

Video link Basic: 

Source codes:
mysql> SHOW DATABASES;

mysql> CREATE DATABASE employees;

mysql> USE employees;


CREATE TABLE IF NOT EXISTS emp (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    age TINYINT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)  ENGINE=INNODB;


mysql> SELECT * FROM emp;

mysql> DESCRIBE emp;

mysql> SHOW TABLES;

mysql> INSERT INTO emp(name, age) VALUES('Fahad', 18);


mysql> exit




Java Codes:
package com.microtech;
import java.sql.*;

public class AnotherTest {

public static void main(String[] args) {
// TODO Auto-generated method stub
try { Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/employees?serverTimezone=UTC", "root", ""); PreparedStatement st = conn.prepareStatement("INSERT INTO emp(name, age) VALUES(?, ?);"); st.setString(1, "Junayed"); st.setShort(2, (short) 12); boolean resultSet = st.execute(); if (!resultSet) System.out.println("Data inserted successfully!"); else System.out.println("Try again!"); } catch(Exception e) { System.out.println("My exception: " + e); } System.out.print("End of the execution!");

}
}

Monday, November 18, 2019

AWS CLI2: install and config on ubuntu 18

Require: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html

Installation on ubuntu:



Saturday, November 9, 2019

Create a bootable USB flash drive

Performed system configuration:
250GB HDD
HP Pavilion Laptop with windows 10 running.


Ruru's configuration details:

Tools configuration:
Boot directly from restart with a UBS3
Bios settings
Rufu Format settings
Result
Legacy
GTP
OK
Legacy
MBR
Format fails
Legacy disabled
GTP
Boot fails
Legacy disabled
MBR
Format fails

Boot directly from restart with a UBS2
Bios settings
Rufu Format settings
Result
Legacy
MBR
Format fails







Boot from windows settings with USB3 (UEFI)
Rufu format: GTP
Result: OK

Tuesday, July 2, 2019

Block dropbox by firewall (mikrotik)

Visit this site to check the ip address which use dropbox.

Dorpbox use these ipaddress: 
162.125.0.0/16
64.124.102.192/30
199.47.216.0/22
108.160.160.0/20
205.189.0.0/24
209.99.70.0/24
45.58.64.0/20

208.185.144.160/27


Before adding those IPs, backup your router configuration files.
Run this on mikrotik terminal:

/ip firewall address-list 
add address=162.125.0.0/16 list=Dropbox
add address=64.124.102.192/30 list=Dropbox
add address=199.47.216.0/22 list=Dropbox
add address=108.160.160.0/20 list=Dropbox
add address=205.189.0.0/24 list=Dropbox
add address=209.99.70.0/24 list=Dropbox
add address=45.58.64.0/20 list=Dropbox
add address=208.185.144.160/27 list=Dropbox



/ip firewall filter
add action=drop chain=forward dst-address-list=Dropbox





Resource: 

Monday, June 24, 2019

How to share a printer in windows 10

To share a printer in windows 10, first enable shairing from the printer connected pc.
Then, from the remote user pc install and check by see bellow picture.





NB: You give print command from the client pc, it might shows that the printer is offline though it print successfully.