是否可以在没有SMTP设置的情况下发送邮件?

时间:2022-01-28 18:13:20

Without SMTP settings like Host, Username and Password I have to send mail. Is it possible in PHP or any some other languages??

如果没有主机,用户名和密码等SMTP设置,我必须发送邮件。是否有可能在PHP或任何其他语言?

1 个解决方案

#1


1  

Yes it is possible to do that using mail() function. However consider then following limitations:

是的,可以使用mail()函数来实现。但请考虑以下限制:

Note: The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine). Second, the custom headers like From:, Cc:, Bcc: and Date: are not interpreted by the MTA in the first place, but are parsed by PHP. As such, the to parameter should not be an address in the form of "Something ". The mail command may not parse this properly while talking with the MTA.

注意:mail()的Windows实现在很多方面与Unix实现有所不同。首先,它不使用本地二进制文件来编写消息,而只是在直接套接字上运行,这意味着需要在网络套接字(可以在本地主机或远程机器上)上侦听MTA。其次,自定义标题如From:,Cc:,Bcc:和Date:首先不是由MTA解释,而是由PHP解析。因此,to参数不应该是“Something”形式的地址。在与MTA通信时,mail命令可能无法正确解析此问题。

 

Note: It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.

注意:值得注意的是mail()函数不适合循环中的大量电子邮件。此功能打开和关闭每个电子邮件的SMTP套接字,效率不高。

#1


1  

Yes it is possible to do that using mail() function. However consider then following limitations:

是的,可以使用mail()函数来实现。但请考虑以下限制:

Note: The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine). Second, the custom headers like From:, Cc:, Bcc: and Date: are not interpreted by the MTA in the first place, but are parsed by PHP. As such, the to parameter should not be an address in the form of "Something ". The mail command may not parse this properly while talking with the MTA.

注意:mail()的Windows实现在很多方面与Unix实现有所不同。首先,它不使用本地二进制文件来编写消息,而只是在直接套接字上运行,这意味着需要在网络套接字(可以在本地主机或远程机器上)上侦听MTA。其次,自定义标题如From:,Cc:,Bcc:和Date:首先不是由MTA解释,而是由PHP解析。因此,to参数不应该是“Something”形式的地址。在与MTA通信时,mail命令可能无法正确解析此问题。

 

Note: It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.

注意:值得注意的是mail()函数不适合循环中的大量电子邮件。此功能打开和关闭每个电子邮件的SMTP套接字,效率不高。