note 39305 modified in ref.mail by danbrown

From: Date: Sun, 17 May 2009 20:22:52 +0000
Subject: note 39305 modified in ref.mail by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155378@lists.php.net to get a copy of this message
If you can't use or don't understand how to use the sendmail program from linux, you can use a PEAR object to send mail. <?php include("Mail.php"); $recipients = "mailto@example.com"; $headers["From"] = "mailfrom@example.com"; $headers["To"] = "mailto@example.com"; $headers["Subject"] = "Test message"; $body = "TEST MESSAGE!!!"; $params["host"] = "example.com"; $params["port"] = "25"; $params["auth"] = true; $params["username"] = "user"; $params["password"] = "password"; // Create the mail object using the Mail::factory method $mail_object =& Mail::factory("smtp", $params); $mail_object->send($recipients, $headers, $body); ?> In my case, i use a smtp server that require authentication, and sendmail configuration is almost cryptic to me. PEAR is already installed in PHP 4.0.3 , if not, you must go to http://pear.php.net/ and install it, in my case, I needed to add the Socket.php to the PEAR library. --was-- If you can't use or don't understand how to use the sendmail program from linux, you can use a PEAR object to send mail. <? include("Mail.php"); $recipients = "mail_to@domain.mail"; $headers["From"] = "mail_from@domain.mail"; $headers["To"] = "mail_to@domain.mail"; $headers["Subject"] = "Test message"; $body = "TEST MESSAGE!!!"; $params["host"] = "smtp.server"; $params["port"] = "25"; $params["auth"] = true; $params["username"] = "user"; $params["password"] = "password"; // Create the mail object using the Mail::factory method $mail_object =& Mail::factory("smtp", $params); $mail_object->send($recipients, $headers, $body); ?> In my case, i use a smtp server that require authentication, and sendmail configuration is almost cryptic to me. PEAR is already installed in PHP 4.0.3 , if not, you must go to pear.php.net and install it, in my case, I needed to add the Socket.php to the PEAR library. http://php.net/manual/en/ref.mail.php

« previous php.notes (#155378) next »