PHP and SMTP server -


my simple code below:

$headers = 'mime-version: 1.0' . "\r\n"; $headers .= 'content-type: text/html; charset=utf-8' . "\r\n"; $headers .= "from: info@mail.com \r\n"; $headers .= 'bcc: test@mail.com' . "\r\n";  $subject = "information";  if (mail($email, $subject, $message, $headers)) {     $mail_status = "success"; } else {     $mail_status = "fail"; }  if ($mail_status == "success") echo '{"status":"success"}'; 

how can support smtp support?

as mentioned phpmailer in tags. can use phpmailer class process.

require_once('../class.phpmailer.php'); //include("class.smtp.php"); // optional,      //gets called within class.phpmailer.php if not loaded  $mail             = new phpmailer();  $body             = file_get_contents('contents.html'); $body             = eregi_replace("[\]",'',$body);  $mail->issmtp(); // telling class use smtp $mail->host       = "mail.yourdomain.com"; // smtp server $mail->smtpdebug  = 2;                     // enables smtp debug information (for testing)                                            // 1 = errors , messages                                            // 2 = messages $mail->smtpauth   = true;                  // enable smtp authentication $mail->host       = "mail.yourdomain.com"; // sets smtp server $mail->port       = 26;                    // set smtp port gmail server $mail->username   = "yourname@yourdomain"; // smtp account username $mail->password   = "yourpassword";        // smtp account password  $mail->setfrom('name@yourdomain.com', 'first last');  $mail->addreplyto("name@yourdomain.com","first last");  $mail->subject    = "phpmailer test subject via smtp, basic authentication";  $mail->altbody    = "to view message, please use html compatible email viewer!"; // optional, comment out , test  $mail->msghtml($body);  $address = "whoto@otherdomain.com"; $mail->addaddress($address, "john doe");  $mail->addattachment("images/phpmailer.gif");      // attachment $mail->addattachment("images/phpmailer_mini.gif"); // attachment  if(!$mail->send()) {   echo "mailer error: " . $mail->errorinfo; } else {   echo "message sent!"; } 

source: http://phpmailer.worxware.com/index.php?pg=examplebsmtp


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -