<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "<<smtpserver>>:<<stmpport>>"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "<<uname>>"; // SMTP username
$mail->Password = "<<pword>>"; // SMTP password
$mail->From = "<<email address from>>";
$mail->FromName = "<<email name from>>";
$mail->AddAddress("<<email address to>>");
$mail->AddReplyTo("<<email address from>>","<<email name from>>");
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Subject";
$mail->Body = "Body text";
$mail->AltBody = $mail->Body;
$mail->Send();
?>
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (6)
Commented:
>>It is ... not built in to the Windows version.
Is this a new 6.X default setting I am not aware of?
Commented:
As long as you know how to build MIME mail, the builtin mail() function is fine.
As of 5.3.0 it can also produce a log of all mail sent.
http://docs.php.net/manual/en/function.mail.php
But there is a significant difference between the win32 and non win32 implementations as summarised in this note on that above page ...
Note: The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine).
Second, the custom headers like From:, Cc:, Bcc: and Date: are not interpreted by the MTA in the first place, but are parsed by PHP.
As such, the to parameter should not be an address in the form of "Something <someone@example.com>". The mail command may not parse this properly while talking with the MTA.
So, whilst it is not perfect, it does exist.
And having said all that, using a class to coordinate all of this is a LOT easier.
Commented:
http://swiftmailer.org/
Regards,
SAkthivel
Commented:
May i know what else setting has to be done on the linux server. So as to send the mail.
Does any services like 'sendmail','postfix','qmai
I want to send the basic mail through my server.
Commented:
PHP Send Mail using SMTP
View More