The company's cloud platform has disabled fsockopen. if you want to use an smtp Internet mailbox to send emails, you can only try to use curl for google first, I found many questions, but I didn't have any answers. I didn't find any related classes in phpclasses. so I started to try curl while reading the stmp protocol.
SMTP protocol
You can find multiple related examples on the internet. you can experiment with telnet to connect to the mail server.
The code is as follows:
$ Telnet email SMTP service address 25
Trying email service IP address...
Connected to mail SMTP service address.
Escape character is '^]'.
Exchange email server address: Microsoft esmtp mail Service ready at Sat, 2 Jun 2012 15:02:12 + 0800
EHLO 127.0.0.1
-Exchange email server address Hello [email service IP address]
-SIZE
-PIPELINING
-DSN
-ENHANCEDSTATUSCODES
X-ANONYMOUSTLS
-AUTH NTLM LOGIN
-X-EXPS GSSAPI NTLM
-8 BITMIME
-BINARYMIME
-CHUNKING
-XEXCH50
XRDST
AUTH LOGIN
VXNlcm5hbWU6
Username (base64_encode)
UGFzc3dvcmQ6
Password (base64_encode)
2.7.0 Authentication successful
Mail from: sending address
2.1.0 Sender OK
Rcpt to: inbox address
2.1.5 Recipient OK
DATA
Start mail input; end .
Content to be sent (there are many related specifications here)
.
2.6.0 <0b476f30-3b96-4e3d-84d2-395a96d34000 @ exchange email server address> Queued mail for delivery
QUIT
2.0.0 Service closing transmission channel
Connection closed by foreign host.
The above is only the php
The package test + modification took nearly six hours to make the product code compatible with fsockopen and curl.
Write an smtp class compatible with fsockopen and curl for simple mail sending.
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.