Send email with socket in PHP (d)

Source: Internet
Author: User
Tags include mail net socket
An example is given below.

Mail Send instance

First, give the simplest example:
<?php
1 include "sendmail.class.php3";
2 $email = "Hello, this is a test letter!";
3 $sendmail =new send_mail ("Smtp.263.net", "Limodou", true); To display the information for an adjustment
4 if ($sendmail->send ("Chatme@263.net", "chatme@263.net", "Test", $email))
5 {
6 echo "Send success!" <br> ";
7}
8 Else
9 {
Ten echo "Send failed!" <br> ";
11}
?>

Line 1th, load the Send_mail class.
Line 3rd, create an instance of the class, and set the display information, if you do not want to display, you can
$sendmail =new send_mail ("smtp.263.net");.
Line 4th, send the message.


It's simple, isn't it? The previous example of sending a MIME message is given below, giving an example of sending an HTML attachment.

<?php

Include "MIME.CLASS.PHP3";
Note, in the text of a MIME message, this class file is named Mime.class, where I change to this

$to = ' chatme@263.net '; Change to Addressee's mailbox
$str = "Newsletter for". Date (' M Y ', Time ());

I've changed the message.
$html _data = ' <body bgcolor= "#ffffff" >
Hello! This is a test!
</body>

Generate MIME class instances
$mime = new Mime_mail ("Chatme@263.net", $to, $STR);

Add HTML attachment
$mime->attach ($html _data, "", HTML, BASE64);

Comment out, using my send mail processing
$mime->send_mail ();

Generate mail
$mime->gen_email ();

Display message Information
echo $mime->email. " <br> ";

Contains sendmail files
Include "SENDMAIL.CLASS.PHP3";

Create an instance
$sendmail =new send_mail ("Smtp.263.net", "Limodou", true);

Send mail
$sendmail->send ("Chatme@263.net", "chatme@263.net", $str, $mime->email);

?>
The notes are clearly written so that no more explanations can be made. If in practice, set debug in the Send_mail constructor to false or not to write.

< finished full >


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.