Knowledge Base Home  l  Web Hosting  l  Softwares  l  WHM  l 

Send the mail using the SMTP authentication through php
Category : WHM

Send the mail using the SMTP authentication through php code. You can use the following code to send the mail.

 


require_once "Mail.php";

// Assign contact info
$name = stripcslashes($_POST['name']);
$emailAddr = stripcslashes($_POST['email']);
$issue = stripcslashes($_POST['issue']);
$comment = stripcslashes($_POST['message']);
$subject = stripcslashes($_POST['subject']);


$host = "localhost";
$username = "mywebsitemail@mywebsiteaddress.com";
$password = "mymailpassword";

// Set headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Format message
$contactMessage =
"<div>
<p><strong>Name:</strong> $name <br />
<strong>E-mail:</strong> $emailAddr <br />
<strong>Issue:</strong> $issue </p>

<p><strong>Message:</strong> $comment </p>

<p><strong>Sending IP:</strong> $_SERVER[REMOTE_ADDR]<br />
<strong>Sent via:</strong> $_SERVER[HTTP_HOST]</p>
</div>";

$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));


$response = ($smtp->send('mymail@mymail.com', $subject, $contactMessage, $headers)) ? "success": "failure";
$output = json_encode(array("response" => $response));
header('content-type: application/json; charset=utf-8');
echo($output);


Growing Business Circleâ„¢
Click here for more ....
      
     Category
 
Web Hosting  l   Softwares  l   WHM  l  
  Most Recent Articles

» Send the mail using the SMTP authentication through php

» This message is to inform you that the account xxxxxx has user id 0 (root privs)

» Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in D:\INETPUB\VHOSTS

» call-time-pass-by-reference error after updating the php to php 5.4

» spamming through exim, Exim is down , /var drive is full

      Popular Articles

» Send the mail using the SMTP authentication through php

» This message is to inform you that the account xxxxxx has user id 0 (root privs)





Copyright © 2014 Adsin Technologies. All rights reserved. Powered by business adsleaf