Email sending program based on the mail service software (IMAIL) under NT-(online version)

Source: Internet
Author: User
If you cannot install IMAIL on the server, you can only send emails through socket. However, if you are lucky, you can also use the smtp service of 163sina. The routine is as follows (the original program is provided by Ma Yi brother): HTMLHEADTITLEMailFormanywhereTITLEHEADBODY? If ($ sendit) {$ smtpserver202.110.200.242; set this to IMail

If you cannot install IMAIL on the server, you can only send emails through socket. However, if you are lucky, you can use 163/sina's

Smtp service.

The routine is as follows (the original program is provided by Ma Yixiong ):


Mail Form anywhere


If ($ sendit)
{
$ Smtpserver = "202.110.200.242"; // set this as the imail ip address
Echo"
";
$ Fp = fsockopen ($ smtpserver, 25, & $ errno, & $ errstr, 10); // connect to the smtp server, port 25
If (! $ Fp) die ("wrong open smtp SERVER ");
$ Hostreplay = fgets ($ fp, 128 );
// If (! Strstr ($ hostreplay, "220") die ("can n' t receive the 220 answer ");
$ Smailname = strstr (ltrim ($ hostreplays), "220 ");
$ Smailname = substr ($ smailname, 0, strpos ($ smailname ,"."));
// Echo "\ nsmailname: $ smailname \ n ";
Fputs ($ fp, "$ smailname \ n ");
$ Hostreplay = fgets ($ fp, 128 );
// If (! Strstr ($ hostreplay, "250") die ("can n' t receive the 250 answer ");

Fputs ($ fp, "mail from: \ n ");
$ Hostreplay = fgets ($ fp, 128 );
If (! Strstr ($ hostreplay, "250 ")){
Fputs ($ fp, "mail from: root \ n ");
$ Hostreplay = fgets ($ fp, 128 );
If (! Strstr ($ hostreplay, "250 ")){
Fputs ($ fp, "mail from: root@263.net \ n ");
Echo ($ hostreplay = fgets ($ fp, 128 ));
If (! Strstr ($ hostreplay, "250 ")){
Fputs ($ fp, "mail from: $ from_address \ n ");
$ Hostreplay = fgets ($ fp, 128 );
If (! Strstr ($ hostreplay, "250") die ("can n' t receive the 250 answer ");
};
};
};
Fputs ($ fp, "rcpt to: $ to_address \ n ");
$ Hostreplay = fgets ($ fp, 128 );
If (! Strstr ($ hostreplay, "250 ")){
Fputs ($ fp, "rcpt to: $ mailname \ n ");
$ Hostreplay = fgets ($ fp, 128 );
If (! Strstr ($ hostreplay, "250") echo ("can n't receive the 354 answer ");
};
Fputs ($ fp, "DATA \ n ");
$ Hostreplay = fgets ($ fp, 128 );
If (! Strstr ($ hostreplay, "354") die ("can n' t receive the 250 answer ");
$ Tosend = "From: $ from_address \ n ";
$ Tosend. = "To: $ to_address \ n ";
$ Tosend. = "Subject:". str_replace ("\ N", "", $ subject). "\ n Hello, this is a test letter from yukuang !!

\ N. \ n ";
Fputs ($ fp, $ tosend );
$ Hostreplay = fgets ($ fp, 128 );
If (! Strstr ($ hostreplay, "250") die ("can n' t receive the 250 answer ");
Fputs ($ fp, "QUIT \ n ");
Fclose ($ fp );
Echo "sent successfully ";
Exit ();
// If ($ ck_name! = 'Root') die ("
Bye ");

};

?>







The program passes debugging in the LAN. my IP address is 202.110.200.242 for testing.

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.