PHP mailer email sending
First, download the class library phpmailer. Because smtp.163.php is loaded, the sender's email address must use the 163 email address, its inbox, and other similar libraries. My attachment. xls is the attachment you want to add, which can be of any type.
Echo"
";
Require_once ('class. phpmailer. php ');
$ Mail = new PHPMailer (); // instantiate
$ Mail-> IsSMTP (); // enable SMTP
$ Mail-> Host = "smtp.163.com"; // The SMTP server uses the 163 email address as an example.
$ Mail-> Port = 25; // mail sending Port
$ Mail-> SMTPAuth = true; // enable SMTP authentication
$ Mail-> CharSet = "UTF-8"; // Character Set
$ Mail-> Encoding = "base64"; // Encoding method
$ Mail-> Username = "yourmail@163.com"; // your mailbox 163
$ Mail-> Password = "password"; // your Password
$ Mail-> Subject = "hello"; // any email title
$ Mail-> From = "youradmin@163.com"; // sender address (that is, your mailbox)
$ Mail-> FromName = "name"; // any sender name
$ Address = "$ _ POST ['email ']"; // the recipient's email is from post. This is the recipient's email.
$ Mail-> AddAddress ($ address, ""); // Add a recipient (address, nickname)
$ Mail-> addattachment('xx.xls', 'My attachment .xls '); // Add the attachment and specify the name
$ Mail-> IsHTML (true); // html content is supported
$ Mail-> AddEmbeddedImage ("logo.jpg", "my-attach", "logo.jpg"); // you can specify an image in the email.
$ Mail-> Body = 'hello,
Friend!
This is an email from helloweba.com!
'; // Subject content
// Send
If (! $ Mail-> Send ()){
Echo "failed to send:". $ mail-> ErrorInfo;
} Else {
Echo "sent successfully! ";
}
?>