Mail Issue
| From: | Paul Singh | Date: | Wed, 07 May 2008 17:05:35 +0000 |
| Subject: | Mail Issue | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-28894@lists.php.net to get a copy of this message | ||
Hello,
I thank you for taking the time to read my post. I just have a simple question
in regards to the code below. The code works perfectly, I am using the NET STMP
class, however I need to have contact name within the FROM address (Basically, I
want my name to appear in the from address..). I've tried 'test
<test@test.ca>', but nothing seems to work.
My code is as follows:
$host = '*****@****.ca';
$from = '*****@****.ca';
$rcpt = array($tempemail);
$subj = "Subject: Registration Confirmation\n";
$body = "Hello ". $_SESSION['tempname'] . ", \n\nYour account is pending
approval, please be patient. ";
/* Create a new Net_SMTP object. */
if (! ($smtp = new Net_SMTP($host))) {
die("Unable to instantiate Net_SMTP object\n");
}
/* Connect to the SMTP server. */
if (PEAR::isError($e = $smtp->connect())) {
die($e->getMessage() . "\n");
}
/* Send the 'MAIL FROM:' SMTP command. */
if (PEAR::isError($smtp->mailFrom($from))) {
die("Unable to set sender to <$from>\n");
}
/* Address the message to each of the recipients. */
foreach ($rcpt as $to) {
if (PEAR::isError($res = $smtp->rcptTo($to))) {
die("Unable to add recipient <$to>: " . $res->getMessage() .
"\n");
}
}
/* Set the body of the message. */
if (PEAR::isError($smtp->data($subj . "\r\n" . $body))) {
die("Unable to send data\n");
}
/* Disconnect from the SMTP server. */
$smtp->disconnect();}?>