如何将用户购物车的产品发送到邮箱
一个简单的功能,php程序是澳大利亚朋友写的,现在他有事,用户购物车里,有一个e-mail咨询点击咨询,用户可以发送他要咨询的问题,和他购物车里的产品图片信息一起发到我的邮箱里,希望有人能帮忙。要不我连工作都没有了。。。
------解决方案--------------------
建议要socket
host = $host;
$this->port = $port;
/*
*使用 base64进行编码。设计此种编码是为了使二进制数据可以通过非纯 8-bit 的传输层传输,例如电子邮件的主体。
*base64-encoded 数据要比原始数据多占用 33% 左右的空间。
*/
$this->user = base64_encode($user);
$this->pass = base64_encode($pass);
$this->debug = $debug;
/*
*创建并返回一个socket资源,也被称为一个通信端点。 client, and another performing the role of the *一个典型的网络连接是由2插座,一个执行的客户端的角色,而另一个执行服务器的角色。
* 域: af_inet .基于ipv4的互联网协议。
* 类型:sock_stream 提供测序,可靠,全双工,基于连接的字节流.一个彻头彻尾的带外数据传输机制可能得到支持。tcp协议是基于此套接字类型。
* 协议:sol_tcp
*/
$this->socket = socket_create (af_inet, sock_stream, sol_tcp); //需在php.ini中打开extension=php_sockets.dll
if($this->socket)
{
$this->result_str = 创建socket:.socket_strerror(socket_last_error());
$this->debug_show($this->result_str);
}
else
{
exit(初始化失败,请检查您的网络连接和参数);
}
$this->conn = socket_connect($this->socket,$this->host,$this->port);
if($this->conn)
{
$this->result_str = 创建socket连接:.socket_strerror(socket_last_error());
$this->debug_show($this->result_str);
}
else
{
exit(初始化失败,请检查您的网络连接和参数);
}
$this->result_str = 服务器应答:.socket_read ($this->socket, 1024).;
$this->debug_show($this->result_str);
}
function debug_show($str)
{
if($this->debug)
{
echo $str.
\r\n;
}
}
function send($from,$to,$subject,$body)
{
if($from == || $to == )
{
exit(请输入信箱地址);
}
if($subject == ) $sebject = 无标题;
if($body == ) $body = 无内容;
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->body = $body;
//_yyy修改部分代码
$all = from:from.>\r\n;
$all .= to:to.>\r\n;
$all .= subject:.$this->subject.\r\n\r\n;
$all .= $this->body;
/*
如过把$all的内容再加处理,就可以实现发送mime邮件了
不过还需要加很多程序
*/
//以下是和服务器会话
$this->in = ehlo helo\r\n;
$this->docommand();
$this->in = auth login\r\n;
$this->docommand();
$this->in = $this->user.\r\n;
$this->docommand();
$this->in = $this->pass.\r\n;
$this->docommand();
// $this->in = mail from:.$this->from.\r\n;
$this->in = mail from:from.>\r\n;
$this->docommand();