Welcome! Log In Create A New Profile

Advanced

[WEBDEV 12] Sending Email in PHP?

Posted by JB 
JB
[WEBDEV 12] Sending Email in PHP?
May 01, 2009 01:16PM
I am confused as it says in the IDE I can't EmailStartSMTPSession is not allowed in PHP.

Has anyone got some example code to show how I send an email in a PHP site please?

Thanks

Jonathan
Piet van Zanten
Re: [WEBDEV 12] Sending Email in PHP?
May 01, 2009 02:50PM
Hi Jonathan,

Don't know about Webdev, but perhaps you can use plain PHP:
//Function to Send out Email
function Send_Email($sFrEmail, $sToEmail,$sSubject, $sSMTP, $sContent)
{
        $content_type = "text/plain";
        $to=$sToEmail;
         /* additional headers */
        $headers = "From: " . str_replace(";", ",", $sFrEmail) . "\r\n";
        /* and now mail it */
        if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
                ini_set("SMTP",$sSMTP);
                //ini_set("smtp_port",$sSMTPSERVER_PORT);
        }
        ini_set("sendmail_from",$sFrEmail);
        if (!mail($to, $sSubject, $sContent, $headers)) {
                ExitError("Er is een fout opgetreden bij het versturen van mail aan " . $sToEmail);
        } else {
                return true;
        }
}
Regards,
Piet
JB
Re: [WEBDEV 12] Sending Email in PHP?
May 01, 2009 03:51PM
Thanks Piet!
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: