View Full Version : Sending email by SMTP
kenmiles
03-01-2008, 05:15 AM
Can someone point me in the right direction to fix this please.
Emails are being sent from postfix and I would like to change this to SMTP via my isp as the emails that go to a hotmail account get rejected but I cannot find how to do this.
Regards, Kenneth.
zolkir
03-01-2008, 01:44 PM
I'm having a similar problem, but I'm completely new to php so I'm much more lost. After the user logs in and submits the ticket, they're supposed to receive an email confirmation with the ticket number. I have my Exchange server setup on another server in the same domain that I'm trying to use to send these emails - this server requires SMTP authentication. Where do I setup the authentication variables to send this email? I tried adding the authentication vars to the smtp.php file in the C:\PHP5\PEAR\Mail directory, but still not authenticating. I'm completely lost, any help is greatly appreciated.
; PHP 5.2.5 installed on Windows Server 2003 with IIS 6
; Mail-1.1.14 mail pkg with Net_SMTP-1.2.11 pkg
kenmiles
03-01-2008, 02:33 PM
If it helps you I searched the forum (which I should have done in the first place) and found the answer was to install phpmailer in the includes/mail/ and create mail.php -
<?
require_once("class.phpmailer.php");
$mail = new phpmailer();
// $mail->Mailer = "mail"; // send via php
$mail->IsSMTP(); // send via SMTP
$mail->Mailer = "smtp";
$mail->Host = "myisp.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentification
$mail->Username = "myusername"; // SMTP username
$mail->Password = "mypassword"; // SMTP password
$mail->From = "noreply@kmiles.co.uk";
$mail->FromName = $fromname;
$mail->AddAddress("$to");
$mail->AddReplyTo("$fromname", "$fromaddress");
// $mail->WordWrap = 50; // set word wrap
// $mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
// $mail->AddAttachment("/tmp/image.jpg", "new.jpg");
// $mail->IsHTML(false); // send as HTML
$mail->Subject = utf8_decode($subject);
$mail->Body = utf8_decode($message);
// $mail->AltBody = "This is the text-only body";
$IsSent = 1;
if(!$mail->Send())
{
echo "email_has_not_been_sent <br><br>";
echo "Mailer Error: " . $mail->ErrorInfo;
$IsSent = 0;
exit;
}
?>
My system is now sending it via my isp which is what I wanted.
By the way I am running a linux system with apache2.
Regards, Kenneth.