Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/default-filters.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/default-filters.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-theme.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-theme.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-styles.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/class-wp-styles.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/block-supports/duotone.php on line 1

Warning: Uninitialized string offset 0 in /home/ujjal/public_html/blog/wp-includes/block-supports/duotone.php on line 1

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768

Warning: Cannot modify header information - headers already sent by (output started at /home/ujjal/public_html/blog/wp-includes/default-filters.php:1) in /home/ujjal/public_html/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1768
{"id":20,"date":"2011-04-01T23:27:54","date_gmt":"2011-04-01T17:27:54","guid":{"rendered":"http:\/\/ujjalruet.wordpress.com\/?p=20"},"modified":"2011-04-01T23:27:54","modified_gmt":"2011-04-01T17:27:54","slug":"sending-mail-from-php","status":"publish","type":"post","link":"https:\/\/blog.ujjal.net\/?p=20","title":{"rendered":"Sending mail from php"},"content":{"rendered":"

Today I am going to post a simple method to send mail from php code.To this we must use SMTP [Simple Mail Transfer protocol]which uses default port that is 25.Before sending mail,SMTP server name must be included in php.ini .To make our job easier I will use three php files.
\nThey are
\n01: SMTPconfig.php
\n02: SMTPclass.php
\n03: index.php<\/p>\n

01: SMTPconfig.php<\/strong><\/p>\n

\/\/Server Address
\n$SmtpServer=”gmail.com”;
\n$SmtpPort=”25″; \/\/default
\n$SmtpUser=”yourgmailid@gmail.com”;
\n$SmtpPass=”yourgmailpassword”;<\/p>\n

Here,SMTP server setup is completed.<\/p>\n

02: SMTPclass.php<\/strong><\/p>\n

class SMTPClient
\n{<\/p>\n

function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
\n{<\/p>\n

$this->SmtpServer = $SmtpServer;
\n$this->SmtpUser = base64_encode ($SmtpUser);
\n$this->SmtpPass = base64_encode ($SmtpPass);
\n$this->from = $from;
\n$this->to = $to;
\n$this->subject = $subject;
\n$this->body = $body;<\/p>\n

if ($SmtpPort == “”)
\n{
\n$this->PortSMTP = 25;
\n}
\nelse
\n{
\n$this->PortSMTP = $SmtpPort;
\n}
\n}<\/p>\n

function SendMail ()
\n{
\nif ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
\n{
\nfputs ($SMTPIN, “EHLO “.$HTTP_HOST.”rn”);
\n$talk[“hello”] = fgets ( $SMTPIN, 1024 );
\nfputs($SMTPIN, “auth loginrn”);
\n$talk[“res”]=fgets($SMTPIN,1024);
\nfputs($SMTPIN, $this->SmtpUser.”rn”);
\n$talk[“user”]=fgets($SMTPIN,1024);
\nfputs($SMTPIN, $this->SmtpPass.”rn”);
\n$talk[“pass”]=fgets($SMTPIN,256);
\nfputs ($SMTPIN, “MAIL FROM: from.”>rn”);
\n$talk[“From”] = fgets ( $SMTPIN, 1024 );
\nfputs ($SMTPIN, “RCPT TO: to.”>rn”);
\n$talk[“To”] = fgets ($SMTPIN, 1024);
\nfputs($SMTPIN, “DATArn”);
\n$talk[“data”]=fgets( $SMTPIN,1024 );
\nfputs($SMTPIN, “To: to.”>rnFrom: from.”>rnSubject:”.$this->subject.”rnrnrn”.$this->body.”rn.rn”);
\n$talk[“send”]=fgets($SMTPIN,256);
\n\/\/CLOSE CONNECTION AND EXIT …
\nfputs ($SMTPIN, “QUITrn”);
\nfclose($SMTPIN);
\n\/\/
\n}
\nreturn $talk;
\n}
\n}
\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/<\/p>\n

03: index.php<\/strong><\/p>\n

include(‘SMTPconfig.php’);
\ninclude(‘SMTPClass.php’);
\nif($_SERVER[“REQUEST_METHOD”] == “POST”)
\n{
\n$to = “to_mailid”;
\n$from = “from_mailid”;
\n$subject = “subject”;
\n$body = “message”;
\n$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
\n$SMTPChat = $SMTPMail->SendMail();
\n}<\/p>\n

Thanks for visiting this…<\/strong>
\nFor more info Click Here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

Today I am going to post a simple method to send mail from php code.To this we must use SMTP [Simple Mail Transfer protocol]which uses default port that is 25.Before sending mail,SMTP server name must be included in php.ini .To make our job easier I will use three php files. They are 01: SMTPconfig.php 02: … <\/p>\n