- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
使用 Delphi,我想使用 winsock 将文本消息发送到我的 Web 服务器,然后使用服务器上的电子邮件 php 功能来发布消息。
首先我完成了发送程序(Procedure SendEmail):它读取一个文本文件(日志)并将其发布到我的服务器。在服务器上,邮件由名为 email.php 的电子邮件 php 函数接收(请参阅下面该函数的内容):
Procedure SendEmail;
var
WSADat:WSAData; // winsock.pas
Texto:TextFile;
Client:TSocket;
Info,Posting,Linha,Content:String;
SockAddrIn:SockAddr_In; // winsock.pas
begin
try
if not FileExists(Log) then exit;
AssignFile(Texto, Log); // text to be sent
Reset(Texto);
while not Eof(Texto) do
begin
ReadLn(Texto, Linha);
Content:=Content+#13#10+Linha;
end;
CloseFile(Texto);
DeleteFile(PChar(Log));
WSAStartUp(257,WSADat);
Client:=Socket(AF_INET,SOCK_STREAM,IPPROTO_IP);
SockAddrIn.sin_family:=AF_INET;
SockAddrIn.sin_port:=htons(80);
SockAddrIn.sin_addr.S_addr:=inet_addr('60.64.10.42'); // myserver IP
if Connect(Client,SockAddrIn,SizeOf(SockAddrIn))=0 then begin
Info:='Sender='+CFG.Email+'&content='+Content;
Posting:='POST /blogwp/email.php HTTP/1.0' #13#10
'Connection: close' #13#10
'Content-Type: application/x-www-form-urlencoded' #13#10
'Content-Length: '+IntToStr(Length(Info)) #13#10
'Host: http://myserver.com' #13#10
'Accept: text/html' +#13#10+#13#10+
Info+#13#10;
Send(Client,Pointer(Posting)^,Length(Posting),0);
end;
CloseSocket(Client);
except
exit;
end;
end;
[... some mutex test...]
end.
服务器端email.php函数说明:
<?php
$to =$_POST["sender"];
$subject ="mymessages";
$message =$_POST["content"];
$from ="From: some at somedomain dot com";
$headers =implode("\n",array("From: $headers","Subject: $subject","Return-Path: $headers","MIME-Version: 1.0?","X-Priority: 3","Content-Type: text/html" ));
$flag = mail($to,$subject,$message,$from); // create variables
if($flag)
{
echo "ok!";
}
else
{
echo "no ok =/";
}
?>
(注意:我已经遵循了 php 邮件功能的指南:http://us3.php.net/manual/en/book.mail.php)
这里的一般想法是不使用 smtp 将消息发送到服务器。但是,据我所知,邮件似乎被丢弃在我的服务器上。我对程序很有信心,但不确定 php 邮件功能。这东西不容易调试。知道出了什么问题吗?或者任何其他看起来相似的解决方案?
任何帮助将不胜感激。谢谢。
[编辑]我还在我的服务器站点上询问有关使用 smtp 的支持。如果不首先进行检查,我似乎无法发送任何邮件(使用 smtp):
We use pop-before-smtp mail authentication. You first need to
check the mail before you can send any. You also do not set smtp authentication in your e-mail client settings. Once you have checked the mail with POP authentication is not needed.
We use POP before SMTP authentication as it is a fairly
secure way to prevent spammers and open relays. Unfortunately, this is the configuration that we have chosen. For users who wish to send out mailing lists, we have the Mailman ValueApp, but for standard emailing, POP before SMTP is how the server is setup.
最佳答案
下面一行是错误的:
$headers =implode("\n",array("From: $headers","Subject: $subject","Return-Path: $headers","MIME-Version: 1.0?","X-Priority: 3","Content-Type: text/html" ));
应该是
$headers =implode("\r\n", array("From: $from","Return-Path: $from","MIME-Version: 1.0","X-Priority: 3","Content-Type: text/html"));
尽管您的邮件服务器可能已损坏并需要“\n”。
此外 $from 应该只是电子邮件地址,不包括“发件人:”。
无需设置主题 header - PHP 会为您完成。
关于php - 在没有smtp的情况下在Delphi中发送电子邮件并在服务器上使用php函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/874965/
大家好,我是 php 和 html 新手,面临问题:SMTP 错误:无法连接到 SMTP 主机。邮件程序错误:SMTP 错误:无法连接到 SMTP 主机。但在本地 xampp 中工作正常,在服务器中出
我希望这个问题不是完全偏离主题。 我一直想知道 SMTP 电子邮件验证。有很多服务(例如 Kickbox.io、Email-Validator.net 等)似乎可以处理 SMTP 验证,而不会阻止其
我正在尝试使用 phpMailer 通过电子邮件向用户发送确认消息。我的代码是这样的: IsSMTP(); // set mailer to use SMTP $mail->Host = "ssl:/
我已经在我的本地机器(Windows 7)上安装了 bugzilla 并且它运行良好。但是当我尝试创建一个新帐户时,它说 There was an error sending mail from it
我有一个将发送大量输出的程序。我只是想知道最大电子邮件附件大小是多少?根据RFC 1870邮件服务器可以拒绝邮件,因为它们太大了,但是使用 SMTP/MIME 时有最大大小吗?我在这方面找不到任何东西
假设我有一个网站,其某些功能需要电子邮件验证(例如用户注册)。当然,我会使用正则表达式验证电子邮件,但曾几何时,我在其他人的代码中看到了 SMTP 验证。 SMTP 验证有哪些优点和缺点? 我可以假设
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 2年前关闭。 Improve thi
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
我正在尝试使用 Vala 和 GLib + GIO 实现一个简单的 SMTP 服务器。 到目前为止,纯文本通信没有问题,但当涉及使用 STARTTLS 的 TLS 时,事情会变得更加困难。 这是我到目
我使用 go 的 net/smtp 发送电子邮件,它对某些电子邮件工作正常但对其他电子邮件无效。我收到 554 5.5.1 Error: no valid recipients 但我很确定我提供了正确
我需要帮助 这是我的代码: require 'PHPMailerAutoload.php'; $mail = new PHPMailer; $mail->isSMTP(); $mail->Host =
我的 joomla 联系表 gmail SMTP 设置不起作用。请参阅下面提交联系表时显示的消息。应该是什么原因?extension=php_openssl.dll 也启用了.. 错误信息-: SMT
我正在尝试使用 Amazon 的 SES/SMTP 发送电子邮件,但出现以下错误: javax.mail.MessagingException:无法连接到 SMTP 主机:email-smtp.us-
在我的Mac终端上,我试图通过telnet将smtp.gmail.com转换为port 587。 在Google Apps(设置为管理Dreamhost域)上,我已配置了中继,如下所示: "Allow
理论上,Request For Comments (RFC) 集包含开发人员构建 SMTP 客户端需要知道的一切。然而,要知道哪些 RFC 需要考虑,哪些可以忽略并不总是那么容易。 有没有人有 RFC
MT 支持 SMTP SendMail,还是我坚持使用 MFMailComposeViewController?现在,我可以使用它(MFMailComposeViewController),但是当我添
很难说出这里问的是什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或言辞激烈,无法以目前的形式合理回答。如需帮助澄清此问题以便可以重新打开,visit the help center . 10年前关
我正在尝试通过 BizTalk SMTP 发送端口发送消息。具体来说,我正在通过编排的“稍后指定”端口发送消息。我的目标是使用我选择的附件文件名将消息正文附加到已发送的电子邮件。 但是,无论我尝试什么
我正在编写一个通过有效的 GMail 用户 ID 和密码发送邮件的应用程序。 我只是想在 Windows XP 命令行上模拟 SMTP 连接,当我在 465 端口 telnet smtp.gmail.
关于从应用程序通过 GMails SMTP 服务器发送的电子邮件被标记为垃圾邮件的问题已经有很多讨论。 阅读其他帖子我无法弄清楚我的问题。我的电子邮件最终仍然是 SPF 中性的。 在我的 *(捕获所有
我是一名优秀的程序员,十分优秀!