I am using a PHP script to send email to one or more recipients. If
multiple recipients, the field "$Email" would be as follows:
email1@whatever.com,email2@whatever.com
The emails seems to be reaching some recipients and not others, in a
pattern that I cannot figure out. Is something wrong with this script
that may be causing this?
<?php
if ($sendemail!="none") {
if (($sendemail=="ups") || ($sendemail=="fedex") ||
($sendemail=="airborne")) {
$title="Tracking Number";
} elseif ($sendemail=="noavs") {
$title="** Problem with your order **";
} else {
$title="Status Update";
}
echo "Start send $title to $Email<br>";
$mail = TempNam("/tmp","$Email");
$fd = fopen($mail,"w");
fputs($fd,"From: Whatever.com <shop@whatever.com>\n"); /* Any Headers
*/
fputs($fd,"To: $Email\n");
fputs($fd,"Subject: Whatever Order $inv $title\n");
fputs($fd,"\n\n"); /* Seperates Header from Body */
fputs($fd,"This email confirms that we have received\n");
fputs($fd,"and processed your order. \n");
fputs($fd,"Your item(s) will ship from our\n");
fputs($fd,"warehouse within the next\n\n");
fputs($fd,"$numdays\n\n");
fputs($fd,"business days\n\n");
fputs($fd,"When the item ships from our warehouse, w\n");
fputs($fd,"will send you another email confirming its\n");
fputs($fd,"shipment, along with the \n");
fputs($fd,"tracking numbers so that you can await and\n");
fputs($fd,"track its arrival! \n\n");
fputs($fd,"When you receive your unit, please be sure\n");
fputs($fd,"and send us a photo of your cat(s) enjoying\n");
fputs($fd,"it for our Kitty Customer Photo Gallery.\n\n");
fputs($fd,"Thank you again for your order and please\n");
fputs($fd,"contact me with any questions that arise.\n\n");
fclose($fd);
system("/usr/sbin/sendmail -oi -t < $mail"); /* pipe to sendmail */
unlink($mail);
echo "<img src=1.gif height=15><p>mailed $Email<p><a
href=index.php3>Home</a>";
}
?> |
Clarification of Question by
coolshop-ga
on
28 Jul 2003 06:00 PDT
Hello
In an effort to eliminate anything stupid on my site, I tracked down
this routine and am now using it. What I am finding is that one
particular vendor is still unable to receive emails generated via this
method:
给多个地址发邮件的类
<?php
////////////////////////////////////////////////////////////
// EmailClass 0.5
// class for sending mail
// parameters
// ----------
// - subject, message, senderName, senderEmail and toList are required
// - ccList, bccList and replyTo are optional
// - toList, ccList and bccList can be strings or arrays of strings
// (those strings should be valid email addresses
//
// example
// -------
// $m = new email ( "hello there", // subject
// "how are you?", // message body
// "paul", // sender's name
// "foo@foobar.com", // sender's email
// array("paul@foobar.com", "foo@bar.com"), // To: recipients
// "paul@whereever.com" // Cc: recipient
// );
//
// print "mail sent, result was" . $m->send();
//
//
//
if ( ! defined( 'MAIL_CLASS_DEFINED' ) ) {
define('MAIL_CLASS_DEFINED', 1 );
class email {
// the constructor!
function email ( $subject, $message, $senderName, $senderEmail,
$toList, $ccList=0, $bccList=0, $replyTo=0) {
$this->sender = $senderName . " <$senderEmail>";
$this->replyTo = $replyTo;
$this->subject = $subject;
$this->message = $message;
// set the To: recipient(s)
if ( is_array($toList) ) {
$this->to = join( $toList, "," );
} else {
$this->to = $toList;
}
// set the Cc: recipient(s)
if ( is_array($ccList) && sizeof($ccList) ) {
$this->cc = join( $ccList, "," );
} elseif ( $ccList ) {
$this->cc = $ccList;
}
// set the Bcc: recipient(s)
if ( is_array($bccList) && sizeof($bccList) ) {
$this->bcc = join( $bccList, "," );
} elseif ( $bccList ) {
$this->bcc = $bccList;
}
}
// send the message; this is actually just a wrapper for
// PHP's mail() function; heck, it's PHP's mail function done right
:-)
// you could override this method to:
// (a) use sendmail directly
// (b) do SMTP with sockets
function send () {
// create the headers needed by PHP's mail() function
// sender
$this->headers = "From: " . $this->sender . "\n";
// reply-to address
if ( $this->replyTo ) {
$this->headers .= "Reply-To: " . $this->replyTo . "\n";
}
// Cc: recipient(s)
if ( $this->cc ) {
$this->headers .= "Cc: " . $this->cc . "\n";
}
// Bcc: recipient(s)
if ( $this->bcc ) {
$this->headers .= "Bcc: " . $this->bcc . "\n";
}
return mail ( $this->to, $this->subject, $this->message,
$this->headers );
}
}
}
?>
|
Request for Question Clarification by
sycophant-ga
on
28 Jul 2003 13:25 PDT
Hi coolshop,
It's hard to imagine why it may not work for only one vendor. But I
doubt the problem lies with PHP.
Are you able to send them an email any other way from that server? Do
you have a shell account you can run pine, elm or mail from?
Check they have properly form DNS records, and that their mail servers
are reachable from the server.
Make sure you se a return address on your emails so that any mail
daemon errors can be returned to you.
If you can, check the mail logs on the server, it maybe that they are
being delivered, but are somehow failing at the user's end.
Tracking down email errors can be a hard job, good luck.
Let me know what you find out, if anything.
Regards,
Sycophant-ga
|