Sendmail is a common program found on most Unix servers, that CGI scripts use to send an e-mail. Most automatic responses and e-mail's you get are sent using sendmail.


Here is a common code snippet for sending mail:




From: Nick Papadopoulos <nick\>

To: $usersemail

Subject: Thank you for becoming a member $userfirstname


Thank you $userfirstname for your interest.



The external program /bin/sendmail might change between servers. Many hosts also create their own version of sendmail for security issues, and might name it like safemail, fastmail etc. Also the path might change like to /usr/lib/sendmail or other. If you want to use sendmail, you will have to check where your host has it installed (usually they will have a F.A.Q. page).


Sendmail is neat, but it is a huge task to debug under windows. Until OptiPerl you could not actually check if the e-mail's text is correct. This is because sendmail does not exist under windows.


However OptiPerl can help you debug scripts that use sendmail. It does not actually send the e-mail (and probably while testing you wouldn't want it to), but displays the text that would be sent to sendmail on UNIX.


To use, simply select Run / Sendmail & date support, and enter the path to sendmail your host uses, like for example:





For the example above we would put:




Then tell optiperl on which drive to copy sendmail. The drive letter should be the same as the script you are debugging, and is usually the C drive.


You are ready. When you run or debug the script, a pop-up should appear with the text that would have been sent. The text is correct if:


  • It has a From:, To:, Subject: headers
  • It has a line between the headers and text


By pressing "send to MAPI" button on the sendmail pop-up, you can actually send the mail using your default mail program (it will go first to it's outbox before sending). OptiPerl will parse the fields and create the message.


icon_exclaim No modifications are needed in your script for this to work.


Using many different sendmail path's


If you test many scripts on different servers, each server might have a different path to sendmail. This is fine. Enter each path in the Sendmail support dialog. Note that because files are copied and directories created, you only need to do this once for each possible path of sendmail. Even if you restart your computer it will still work. To remove sendmail, manually delete the folders c:\bin\ or c:\usr\lib\ (created depending on the sendmail path you entered) with all their contents.


Date support


OptiPerl also supports another common external program found in UNIX, date. Example:


print `/bin/date`;


This produces something like:


Sun Jul 12 16:55:51 EDT 2002


To support date, enter it's path (which again varies among servers) in the dialog in menu Run / Sendmail & Date support.




Top  Previous  Next