Send emails in the BAE Environment

Source: Internet
Author: User
The mail function is disabled in the BAE environment. To send emails, you can use the smtp method to send the following reference content: 1BAE uses socket series functions to send emails through the smtp protocol. 2 PHPSOCKET () sends emails 3PHPMailer, 1. Mail can be sent, but it is too simple. The most basic mail communication content, without the recipient and title, content 2 and 3 is always discounted.

The mail function is disabled in the BAE environment. You can use smtp to send emails as a reference. 1. Use socket functions in BAE to send emails through smtp protocol. 2. php socket () method to send mail 3 PHPMailer where, 1 can send mail, but it is too simple, the most basic mail communication content, no recipient and title, content 2 and 3 Total discount

The mail function is disabled in the BAE environment. You can send emails through smtp.

Refer to the following content:
1. Use socket series functions in BAE to send emails through smtp protocol
2. send an email using php socket ()
3 PHPMailer

Among them, 1 can send mail, but it is too simple, the most basic mail communication content, no recipient, title, content
2 and 3 won't make any effort.

Modify the Code 1 to add the following content:



$ Server = "smtp.163.com ";
$ Port = 25; // The default value is 25.
$ Username = "YOURNAME@163.com ";
$ Password = "YOURPASSWORD"; // password
$ Sendto = "TOWHO@gmail.com"; // email recipient address
$ Subject = "test title2 ";
$ Content = "test content2 ";

$ Header = "MIME-Version: 1.0 \ r \ n ";
$ Header. = "To:". $ sendto. "\ r \ n ";
$ Header. = "From: $ username <$ username> \ r \ n ";
$ Header. = "Subject:". $ subject. "\ r \ n ";

$ Data = $ header. "\ r \ n". $ content; // email content

$ Sock = socket_create (AF_INET, SOCK_STREAM, SOL_TCP );
If (socket_connect ($ sock, $ server, $ port) === false) socket_strerror (socket_last_error ());
Echo fig ($ sock, 100 )."";
Socket_write ($ sock, "HELO lyz810 \ r \ n ");
Echo fig ($ sock, 100 )."";
Socket_write ($ sock, "auth login \ r \ n ");
Echo fig ($ sock, 100 )."";
Socket_write ($ sock, base64_encode ($ username). "\ r \ n ");
Echo fig ($ sock, 100 )."";
Socket_write ($ sock, base64_encode ($ password). "\ r \ n ");
Echo fig ($ sock, 100 )."";
Socket_write ($ sock, "mail from: <". $ username. "> \ r \ n ");
Echo fig ($ sock, 100 )."";
Socket_write ($ sock, "rcpt to: <". $ sendto. "> \ r \ n ");
Echo fig ($ sock, 100 )."";
Socket_write ($ sock, "DATA \ r \ n ");
Echo fig ($ sock, 100 )."";
Socket_write ($ sock, $ data. "\ r \ n. \ r \ n ");
Socket_write ($ sock, "QUIT ");
Echo fig ($ sock, 100 )."";

Original article address: send an email in the BAE environment. Thank you for sharing your email.

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.