fake sendmail for windows
作者:成功就要付出 日期:2008-7-16 20:26:00
fake sendmail
© 2004-2008 byron jones
bsd license
glob.com.au/sendmail
sendmail @ glob.com.au

about

sendmail.exe is a simple windows console application that emulates sendmail's "-t" option to deliver emails piped via stdin.

it is intended to ease running unix code that has /usr/lib/sendmail hardcoded as an email delivery means.

it doesn't support deferred delivery, and requires an smtp server to perform the actual delivery of the messages.

install

  • download sendmail.zip
  • copy sendmail.exe and sendmail.ini to \usr\lib on the drive where the unix application is installed
    eg. if your application is installed in c:\bugzilla, sendmail.exe and sendmail.ini need to be copied to c:\usr\lib\sendmail.exe and c:\usr\lib\sendmail.ini.
  • configure smtp server and default domain in sendmail.ini
  • if you require TLS/SSL support, download sendmail-SSL.zip and extract into the same directory as sendmail.exe

or download the installer (for bugzilla installs).

some people have has performance issues using my fake sendmail with gmail's smtp servers (due to SSL/TLS). msmtp may be a viable alternative to fake sendmail.

using fake sendmail

generally all you need to do is install sendmail.exe in \usr\lib, and existing code that calls /usr/lib/sendmail will work.

if you're coding new applications, all you need to do is construct your email message with complete headers, then pipe it to /usr/lib/sendmail -t

for example, to use fake sendmail from the command line:

@ECHO OFF
REM send email from command line via SMTP with sendmail

ECHO From: byron@example.com > %TEMP%\temp.mail
ECHO To: someone-else@example.com. >> %TEMP%\temp.mail
ECHO Subject: this is a test >> %TEMP%\temp.mail
ECHO.>> %TEMP%\temp.mail
ECHO testing. >> %TEMP%\temp.mail
ECHO blah blah.. >> %TEMP%\temp.mail
ECHO. >> %TEMP%\temp.mail
ECHO blah. >> %TEMP%\temp.mail

sendmail -t < %TEMP%\temp.mail

DEL %TEMP%\temp.mail

note ECHO. puts a blank line in the file, not a line with a single period on it.

note: if you have IIS installed, you can send emails without any third party programs (you do NOT need my sendmail wrapper).

@ECHO OFF
REM send email from command line via IIS

REM change this path to point to IIS's pickup directory
SET root=c:\InetPub\MailRoot\Pickup

REM set up temp and eml filenames
IF NOT EXIST %root%\temp MKDIR %root%\temp
:setTempFileName
SET tmp=%RANDOM%
IF EXIST %root%\temp\%tmp%.tmp GOTO setTempFileName
SET eml=%root%\%tmp%.eml
SET tmp=%root%\temp\%tmp%.tmp

REM build the email.  ^ is the escape character
ECHO From: bob.smith@example.com> %tmp%
ECHO To: sally.jones@example.com>> %tmp%
ECHO Subject: Example>> %tmp%
ECHO Content-Type: text/html>> %tmp%
ECHO.>> %tmp%
ECHO ^<b^>This is a test^</b^>>> %tmp%

REM move the temp file into the pickup directory for delivery
RENAME %tmp% %eml%

troubleshooting

range check error

i've had a few reports of sendmail returning a "range check error". i have tracked this to a bug in the indy sockets library and it has been fixed in version 18. see bug 63 for details.

socket error # 10053 software caused connection abort

some anti-virus product limit what applications are allowed to send mail via port 25 (SMTP). ensure that sendmail.exe is in your list of approved applications.

socket error # 11004 valid dns name - no data record of requested type

socket error 11004 means that the dns server which sendmail is talking to does not have a record of the appropriate type for the com puter name which it was looking up.

this can happen if the dns server is currently incorrectly configured (check with your isp, or whoever is running the dns server you are using) or because you should be using a different computer name which would have an a record defined.

in some cases it can also happen because you are using the incorrect dns server addresses (eg using the dns servers of one isp when you are dialing into a second isp).

572 relay not authorized, 554 Relay access denied

it means that you have been denied access to that smtp server by its administrator. administrators prevent abuses of their smtp relay servers by requiring that you send e-mail only from a computer connected to their network, or that you use some type of authentication.

talk to the server's administrator and ask what are the requirements for connecting to the server. sometimes, the server may need to be reconfigured.

debug logging

uncomment the debug_logfile entry in sendmail.ini resend a failed message. this should create debug.log in the same directory as sendmail.exe showing the complete SMTP transcript.

help and support

if you require assistance in setting up sendmail, please follow the directions on the help page.

license and source

this program is released under the bsd license.

the license details and full source (delphi 2005) are included in the zip.

version history

  version 23 apr 24, 2008
    - fix timezone in date header

  version 22 jan 14, 2008
    - fixes to error handling

  version 21 jan 2, 2008
    - added TLS support

  version 20 apr 3, 2007
    - fixed race condition in IIS's pickup delivery

  version 19 jul 24, 2006
    - added support for delivery via IIS's pickup directory
    - optionally reads settings from the registry (in absense of the ini file)

  version 18 may 1, 2006
    - fix for indy 10 "range check error"

  version 17 nov 2, 2005
    - only process message header
    - optionally use madexcept for detailed crash dumps
    - added smtp_port setting

  version 16 sep 12, 2005
    - send hostname and domain with HELO/EHLO
    - configurable HELO/EHLO hostname
    - upgraded to indy 10

  version 15 aug 23, 2005
    - fixes error messages when debug_logfile is not specified

  version 14 jun 28, 2005
    - errors output to STDERR
    - fixes for delphi 7 compilation
    - added 'connecting to..' debug logging
    - reworked error and debug log format

  version 13 jun 8, 2005
    - added fix to work around invalid multiple header instances

  version 12 apr 30, 2005
    - added cc and bcc support

  version 11 feb 17, 2005
    - added pop3 support (for pop before smtp authentication)

  version 10 feb 11, 2005
    - added support for specifying a different smtp port

  version 9 sep 22, 2004
    - added force_sender

  version 8 sep 22, 2004
    - *really* fixes broken smtp auth

  version 7 sep 22, 2004
    - fixes broken smtp auth
 
  version 6 sep 22, 2004
    - correctly quotes MAIL FROM and RCPT TO addresses in <>

  version 5 sep 16, 2004
    - now sends the message unchanged (rather than getting indy
      to regenerate it)

  version 4 aug 17, 2004
    - added debug_logfile parameter
    - improved error messages

  version 3 jul 15, 2004
    - smtp authentication support
    - clearer error message when missing from or to address
    - optional error logging
    - adds date header if missing

  version 2 jul 6, 2004
    - reads default domain from registry (.ini setting overrides)

  version 1 jul 1, 2004
    - initial release

发表评论:

    昵称:
    密码:
    主页:
    标题:
    loading...

1.请遵守《中国互联网行业自律条款》及中华人民共和国其他各项有关法律法规。
2.严禁发表危害国家安全、损害国家利益、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的评论 。
3.用户需对自己在使用本站服务过程中的行为承担法律责任(直接或间接导致的)。
4.本站管理员有权保留或删除评论内容。
评论内容只代表网友个人观点,与本网站立场无关。