| <?php |
| //new function |
| $to = "you@your-domainname.com"; |
| $nameto = "Who To"; |
| $from = "script@your-domainname.com"; |
| $namefrom = "Who From"; |
| $subject = "Hello World Again!"; |
| $message = "World, Hello!"; |
| authSendEmail($from, $namefrom, $to, $nameto, $subject, $message); |
| ?> |
| <?php |
| /* * * * * * * * * * * * * * SEND EMAIL FUNCTIONS * * * * * * * * * * * * * */ |
| //This will send an email using auth smtp and output a log array |
| //logArray - connection, |
| function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message) |
| { |
| //SMTP + SERVER DETAILS |
| /* * * * CONFIGURATION START * * * */ |
| $smtpServer = "mail.ukdns.biz"; |
| $port = "25"; |
| $timeout = "30"; |
| $username = "your-email-address@domain.com"; |
| $password = "Your-POP3-Password"; |
| $localhost = "mail.ukdns.biz"; |
| $newLine = "\r\n"; |
| /* * * * CONFIGURATION END * * * * */ |
| //Connect to the host on the specified port |
| $smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout); |
| $smtpResponse = fgets($smtpConnect, 515); |
| if(empty($smtpConnect)) |
| { |
| $output = "Failed to connect: $smtpResponse"; |
| return $output; |
| } |
| else |
| { |
| $logArray['connection'] = "Connected: $smtpResponse"; |
| } |
| //Request Auth Login |
| fputs($smtpConnect,"AUTH LOGIN" . $newLine); |
| $smtpResponse = fgets($smtpConnect, 515); |
| $logArray['authrequest'] = "$smtpResponse"; |
| //Send username |
| fputs($smtpConnect, base64_encode($username) . $newLine); |
| $smtpResponse = fgets($smtpConnect, 515); |
| $logArray['authusername'] = "$smtpResponse"; |
| //Send password |
| fputs($smtpConnect, base64_encode($password) . $newLine); |
| $smtpResponse = fgets($smtpConnect, 515); |
| $logArray['authpassword'] = "$smtpResponse"; |
| //Say Hello to SMTP |
| fputs($smtpConnect, "HELO $localhost" . $newLine); |
| $smtpResponse = fgets($smtpConnect, 515); |
| $logArray['heloresponse'] = "$smtpResponse"; |
| //Email From |
| fputs($smtpConnect, "MAIL FROM: $from" . $newLine); |
| $smtpResponse = fgets($smtpConnect, 515); |
| $logArray['mailfromresponse'] = "$smtpResponse"; |
| //Email To |
| fputs($smtpConnect, "RCPT TO: $to" . $newLine); |
| $smtpResponse = fgets($smtpConnect, 515); |
| $logArray['mailtoresponse'] = "$smtpResponse"; |
| //The Email |
| fputs($smtpConnect, "DATA" . $newLine); |
| $smtpResponse = fgets($smtpConnect, 515); |
| $logArray['data1response'] = "$smtpResponse"; |
| //Construct Headers |
| $headers = "MIME-Version: 1.0" . $newLine; |
| $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine; |
| $headers .= "To: $nameto <$to>" . $newLine; |
| $headers .= "From: $namefrom <$from>" . $newLine; |
| fputs($smtpConnect, "To: $to\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n"); |
| $smtpResponse = fgets($smtpConnect, 515); |
| $logArray['data2response'] = "$smtpResponse"; |
| // Say Bye to SMTP |
| fputs($smtpConnect,"QUIT" . $newLine); |
| $smtpResponse = fgets($smtpConnect, 515); |
| $logArray['quitresponse'] = "$smtpResponse"; //insert var_dump here -- uncomment out the next line for debug info //var_dump($logArray); |
| } |
| ?> |
.
Thursday, 25 September 2014
Subscribe to:
Post Comments (Atom)
.
Popular Posts
-
You can follow these instructions if you need to manually perform a phpBB installation for your web site. Note that you should skip this s...
-
Conversion rates actually increase if you use other terminology for the button text. According to Hubspot , you can increase your convers...
-
Joomla is one of the most popular Content Management Systems (CMS) in the world, used in over 30 million sites, with over 200,000 communi...
-
Types of Encryption - Conventional Methods Encryption - Decryption: To carry sensitive information, such as military or financial data, a sy...
-
In this SMF introductory installation tutorial, we will demonstrate how to install the Simple Machine Forums (SMF) program manually. A man...
-
Simple Login logout system using php Login and logout system is the most important thing for the user management, session management is on...
-
Try Joomla 3 Now! We’ve partnered with Siteground to provide a 90-day free Joomla! demo account . Get an instant Joomla website today! Try ...
-
CSS3 Animations With CSS3, we can create animations, which can replace animated images, Flash animations, and JavaScripts in many web pages....
-
As a PHP developer, we often get bored with one PHP framework and looks for some advanced feature rich framework which can make life easie...
-
WEBDEC Technologies The penetration of web and digital media into every aspect of people’s lives has caused fundamental changes in how peo...
Powered by Blogger.
0 comments:
Post a Comment