Jump to content

code to send email via smtp host


dazzathedrummer

Recommended Posts

<!-- send mail using  an smtp-->

<?php
require_once "Mail.php";

$from = "[email protected]";
$to = "[email protected]";
$subject = "Hi!";
$body = "<h1>Hi</h1>,\n\nHow are you?";


$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";
$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
  echo("<p>Message successfully sent!</p>");
}
?>

 

try with this

these are my servers sendmail settings: -

 

sendmail_from no value - no value

sendmail_path - /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i

serialize_precision 100 100

short_open_tag On On

SMTP - localhost localhost

smtp_port - 25

 

How do I change the code to use sendmail??

 

try

this

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.