Many people want to send smtp email through wordpress. WordPress uses the PHPmailer in there CMS. Using PHPmailer you can send the email using STMP service.
send smtp email through wordpress
But many wordpress developer dont know how to use the wordpress phpmailer functionality. Using PHPmailer you can send the email using STMP service.
send smtp email through wordpress
send smtp email through wordpress, wordpress send email smtp
Many people use the wordpress plugins for sending the email. But I recommend not to use any wordpress plugin code for this. Because many of wordpress plugin code are not necessary and that will not useful for your wordpress application.
Here in this article I will show you how to sent email using wordpress with SMTP settings.
Use the following code for this:
[viral-lock message=”Source code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
// SMTP email sent
require_once ABSPATH . WPINC . '/class-phpmailer.php';
require_once ABSPATH . WPINC . '/class-smtp.php';
$phpmailer = new PHPMailer();
$phpmailer->SMTPAuth = true;
$phpmailer->Username = 'Username';
$phpmailer->Password = 'password';
$phpmailer->IsSMTP(); // telling the class to use SMTP
$phpmailer->Host = "hostname.com"; // SMTP server
$phpmailer->FromName = $_POST[your_email];
$phpmailer->Subject = $_POST[your_subject];
$phpmailer->Body = $_POST[your_message]; //HTML Body
$phpmailer->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$phpmailer->WordWrap = 50; // set word wrap
$phpmailer->MsgHTML($_POST[your_message]);
$phpmailer->AddAddress('support@purabtech.in/files/', 'Wordpress support');
//$phpmailer->AddAttachment("images/phpmailer.gif"); // attachment
if(!$phpmailer->Send()) {
echo "Mailer Error: " . $phpmailer->ErrorInfo;
} else {
echo "Message sent!";
}
[/viral-lock]
Use the above code for sending the email from wordpress. With godaddy hosting service above code is very useful for creating the contact us page.
Many wp developers asked me where to add the above code. So here is answer. You can create wordpress theme template page. Like contact us page and add the above code in that page according to your requirement.
creating sub domain for wordpress images is best way to increase your wordpress site speed. We given steps to, how to serve wordpress images from sub domain. Many shared hosting and wordpress bloggers and websites are using the apache web server for hosting the wordpress sites. Apache Web server is having his own rules and behavior. By default when you open webpage of your website. That time you are making so many requests to apache web server with same domain name. That will create queue to apache web server with same domain name.
how to serve wordpress images from subdomain
For reducing the load time you should keep image file on different sub domain. Means though image subdomain you can send a parallel request to Apache web server. It will reduce the concurrent connections to web server. WordPress provides the functionality to set different domain or sub domain for images.
In this article I will show you how easily you can set the wordpress images from sub domain. First create subdomain through your control panel. Use following step for creating subdomain.
how to serve wordpress images from subdomain
I recommend to create the images subdomain because images subdomain is good for SEO. Here I created the purabtech.in/files/ subdomain for my images. Then set your wordpress images path in document root setting. Normally your wordpress images are stored in wp-content/uploads directory. You can use following setting for setting the document root.
how to serve wordpress images from subdomain
After creating subdomain for images and setting up the correct document root for images subdomain. Go to your wordpress admin panel. From right side panel you should go to settings -> Media panel. This page will look like as follows:
how to serve wordpress images from subdomain
In “Full URL path to files” textbox put your image subdomain name and click on save changes button. Uncheck the organize my uploads into month- and year-based folder option because which is not good for SEO purpose.
After this your images will come from image subdomain but old uploaded image files will still come from older location and same domain. For changing the older images file location and domain information you should use the following steps.
Go to your Mysql databases and select the your wordpress database. You can use the phpmyadmin sql manager for this or you can use command prompt for this if you are having dedicated hosting server. If you taken shared hosting then I recommend to use PhpMyAdmin.
Use following two SQL query: (Note: You should use your images subdomain and your domain name in SQL query)
UPDATE wp_posts SET post_content = REPLACE(post_content,'http://images.purabtech.in/','http://images.purabtech.in/');
UPDATE wp_posts SET guid = REPLACE(guid,'http://images.purabtech.in/','http://images.purabtech.in/');
After this your old images files will point to images subdomain. If your images and wordpress website is old then google and other search engines already indexed your images. So We need to write the redirection rewrite rule for images in your .htaccess file. This file you will find in your Root directory of wordpress installation.
Use following line of code in your .htaccess file.
RewriteEngine On
RewriteBase /
RedirectMatch 301 ^/wp-content/uploads/(.*)$ http://images.purabtech.in/$1
Above all steps are important to change the wordpress images into images subdoamin. If you are having any issues or questions about this article. Then please write to me.
Confused how to configure load balancer on Amazon. Here we given you detail instructions about How to configure haproxy load balancing on amazon EC2
Many people take amazon EC2 cloud hosting. Amazon does gives the load balancer for application load balancing. But Amazon load balancer is not that much good. Amazon load balancer is not working on hardware or software base. That balancer just sending request to server one by one. Many people confused how to configure load balancer on Amazon EC2.
Here I am going to give you detail instructions about setting up the HaProxy load balancer on Amazon EC2.
How to configure haproxy load balancing on amazon ec2
What is Haproxy?
AProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for web sites crawling under very high loads while needing persistence or Layer7 processing. Supporting tens of thousands of connections is clearly realistic with todays hardware. Its mode of operation makes its integration into existing architectures very easy and riskless.
How to configure haproxy load balancing on amazon ec2
For Haproxy load balancing I recommend to create the micro instance first. Then login to micro instance and install haproxy on that machine. I taken the Centos 5.0 virgin os. Use following command for install the haproxy.
#yum install haproxy
Then Open the haproxy config file.
# vi /etc/haproxy.cfg
For detail configuration you should read the Haproxy config documentation.
Haproxy’s default load balancing style is roundrobin. Which is trusted and good. With this load balancing I am serving around two million pages daily. Means I am handling 6 to 7 million requests per day. I am not having any issues.
I used the three backend server for delivery of my application and one server for serving the static data which is having images and js and css and application files.
Here is my configuration file
global
maxconn 4096 # Total Max Connections. This is dependent on ulimit
daemon
nbproc 4 # Number of processing cores. Dual Dual-core Opteron is 4 cores for example.
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option dontlognull
option httpclose
option httplog
option forwardfor
option redispatch
timeout connect 10000 # default 10 second time out if a backend is not found
timeout client 300000
timeout server 300000
maxconn 60000
retries 3
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
#frontend main *:80
frontend http-in
bind :80
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js
acl url_stats path_beg /haproxy-stats
use_backend be_stats if url_stats
use_backend static if url_static
default_backend app
#-------------------------------------------------
#back-end statistics section
#----------------------------------------------------------------
backend be_stats
stats uri /haproxy-stats
# stats show-node
#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
balance roundrobin
server static 10.211.164.138:80 check
#server static 10.211.185.111:80 check
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
balance roundrobin
server app1 10.214.284.241:80 check
server app2 10.208.168.131:80 check
server app3 10.212.158.126:80 check
You can use the above code in haproxy.cfg file. You just need to change the IP address which are listed under backend static and backend app section. You just put your static server(amazon EC2 instance’s internal IP address).
You should use internal IP address of server because that will reduce the bandwidth uses of Amazon EC2 server. Do not use the public IP address for load balance because that will cost you.
Put application database and application files on all the server. Point your domain to your load balancer machine’s Public IP address.
Let say your application is running on following domain.
www.YOURDOMAIN.COM – point to Load balancer macine.
Open your all application and static server’s apache configuration file. put following entry in that file.
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName www.YOURDOMAIN.COM
# Other directives here
</VirtualHost>
after this just restart the apache server of all servers.
If you are having any issues or questions about setting up the haproxy on amazon EC2 server Please write to me.
Code for File upload with meta box in wordpress using custom post type using meta boxes in wordpress. From wordpress 3.0 version wordpress introduced the custom_post_type function. Many people want to attach the file field with add_meta_box function. In this tutorial I will tell you how to upload file with custom meta box and post type. I tested above code with new wordpress versions 3.9. Still code is working fine.
Code for File upload with meta box in wordpress using custom post type using meta boxes in wordpress.
In this tutorial I will show you how to create the custom post type and add custom meta boxes to that post type and upload file with custom meta box.
After digging into wordpress files and functions I created following code. Just open your functions.php file and put following code in that file for creating custom post type.
For uploading the file through custom meta box use the following code. Following code will add the file field to custom meta box and you are able to upload file or image to wordpress and upload file attachment to you custom post. Following code is very helpful to many wordpress theme and plugin developer. If you are having any issues or trouble using code then get back to me.
File upload with add_meta_box or custom_post_type in wordpress File upload with meta box in wordpress
For Uploading the file your post form need to add the enctype=”multipart/form-data” type to your form. Just use the following code in your functions.php file.
[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
From wordpress 3.0 version release wordpress gives the facility to add a custom post type functionality. With custom post type wordpress is became more powerful and expendable and more advanced We given info about, How to use custom post type in wordpress.
How to use custom post type in wordpress
WordPress recognized the need to people and industry and they introduced the custom post type. In this tutorial I will tell you how to use the custom post type very effectively.
Adding Custom post type is very easy. Using theme or plugin file you can add the custom post types in wordpress admin area.
Here I am going to give you example using wordpress theme files. Open you functions.php file and copy paste the following code in that file.
The function register_post_type() accepts two arguments: the name we want to give our post type, and a list of arguments used to create that post type, which we put in an array called $args.
Using above code that code will add the product post type to wordpress panel.
Now you can add the meta fields to custom post type. Use the following code in file for add the meta fields. Custom meta fields function is available from quite some time. add_meta_box() function is very useful to adding custom fields to wordpress post.
Using following code you can see the product information in edit product page and you can able to see the all information in for edit. Admin will know which fields are available to edit.
Using custom post type and add meta tag you can develop very nice applications. Now I am going to show you how you can extract the custom posts in wordpress frontend.
Using wp_query you can easily extract product posts. In any category page or conditionally you can use following code.
Or you can create the custom theme page using following code. Just create product.php page in your wordpress theme folder.Put following code in that file.
There are many articles we can found for to connect to amazon ec2 machine though ssh. But all I found for windows. Using putty and putty key gen tool you can connect to amazon ec2 linux machine.
How to connect amazon instance through linux command prompt
How to connect amazon instance through linux command prompt
If you are having the linux box and you want to connect to amazon ec2 machine then that is very easy. You just need to install the following package to connect to amazon ec2 machine.
Install the ec2-api-tools on linux or mac machine. use the following command.
# yum install ec2-api-tools
When you first try to create the amazon instance that time you need to create the key pair file. You got the .pem file as key pair file. That file is very important for connecting to amazon instance machines.
Keep your key pair file(.pem ) in safe location and dont give this file anyone. Go to directory where you kept the key pair file.
We given steps for install memcached on centos. Memcached server is used for increase server performance and response time. Here we given the commands for installing memcached on centos.
how to install memcached on centos
I always need to install the memcached on my linux servers like fedora or centos. On fedora box installing the memcached is very easy through yum install. But Centos installing and using memcached is not so easy.
how to install memcached on centos
For my Ruby on Rails and PHP applications I always need to install the memcached on server. Here I am going to give you the steps for installing the memcached.
Very important note: you need to install the gcc compiler for memcached binary installation. Using the memcached with php installation you need the phpize and php-pecl-memcached installed. follow my steps and memcached binary installation.
# yum install gcc*
# cd /usr/src
# wget http://pecl.php.net/get/memcache-2.2.5.tgz
# tar zxvf memcache-2.2.5.tgz
# cd memcache-2.2.5
# phpize
# ./configure
# make
# make install
For checking the php.ini file path use following command.
For many application we need to install the imagemagick on Centos linux server. Many Ruby on rails and PHP applications need the support of imagemagick for image resizing.
How to install imagemagick binary on CentOS
How to install imagemagick binary on CentOS
We all the very traditional way of installing the application on linux machine which is as follows:
# yum install imagemagick
This command will not install the imagemagick on Centos properly. So use following commands for installing the imagemagick on centos
Here in this article we have collected 35 Outstanding free twitter backgrounds. select 35 free best and beautiful twitter backgrounds for Twitter addicts.
Nowadays twitter is a great website for social networking. Many people likes beautiful and creative backgrounds for their twitter profile. People don’t have enough time to search background designs for twitter that’s why we have searched.
35 Outstanding free twitter backgrounds
Note: Click on background images from link
Hope you’ll find useful in this post, you can tell us which background you like through your comments. Thanks!
Many times php developers want to encode there php or important HTML,CSS or Javascript code. In this article I will show you the very simple encoding with using base64_encode method.
php encode and decode string with key
php encode and decode string with key
Here is working example.
<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
$str = 'This is an encoded string';
echo base64_encode($str);
echo base64_decode("VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==");
?></pre>
<pre>
you can create your own antilogarithm for encoding. For more information you can check the following URL