Add checking for duplicate addresses as per https://sourceforge.net/tracker2/?func=detail&aid=1830473&group_id=26031&atid=385709 thanks to Carl Corliss and Me
Note that it doesn't apply this restriction to ReplyTo as it's not unreasonable to have an address you're sending to also being a reply address Add a GetAttachments function, which is needed to stop unit test from breaking (attachments are private)
This commit is contained in:
parent
71d07b4787
commit
91b3277e88
|
|
@ -265,6 +265,7 @@ class PHPMailer {
|
|||
private $cc = array();
|
||||
private $bcc = array();
|
||||
private $ReplyTo = array();
|
||||
private $all_recipients = array();
|
||||
private $attachment = array();
|
||||
private $CustomHeader = array();
|
||||
private $message_type = '';
|
||||
|
|
@ -333,12 +334,17 @@ class PHPMailer {
|
|||
* Adds a "To" address.
|
||||
* @param string $address
|
||||
* @param string $name
|
||||
* @return void
|
||||
* @return boolean true on success, false if addressed already used
|
||||
* @author Marcus Bointon <coolbru at users.sourceforge.net>
|
||||
* @author Carl Corliss <rabbitt at users.sourceforge.net>
|
||||
*/
|
||||
public function AddAddress($address, $name = '') {
|
||||
$cur = count($this->to);
|
||||
$this->to[$cur][0] = trim($address);
|
||||
$this->to[$cur][1] = $name;
|
||||
if (!isset($this->all_recipients[strtolower(trim($address))])) {
|
||||
$this->to[] = array(trim($address), $name);
|
||||
$this->all_recipients[strtolower(trim($address))] = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -347,12 +353,15 @@ class PHPMailer {
|
|||
* mailer.
|
||||
* @param string $address
|
||||
* @param string $name
|
||||
* @return void
|
||||
* @return boolean true on success, false if addressed already used
|
||||
*/
|
||||
public function AddCC($address, $name = '') {
|
||||
$cur = count($this->cc);
|
||||
$this->cc[$cur][0] = trim($address);
|
||||
$this->cc[$cur][1] = $name;
|
||||
if (!isset($this->all_recipients[strtolower(trim($address))])) {
|
||||
$this->cc[] = array(trim($address), $name);
|
||||
$this->all_recipients[strtolower(trim($address))] = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -361,12 +370,15 @@ class PHPMailer {
|
|||
* mailer.
|
||||
* @param string $address
|
||||
* @param string $name
|
||||
* @return void
|
||||
* @return boolean true on success, false if addressed already used
|
||||
*/
|
||||
public function AddBCC($address, $name = '') {
|
||||
$cur = count($this->bcc);
|
||||
$this->bcc[$cur][0] = trim($address);
|
||||
$this->bcc[$cur][1] = $name;
|
||||
if (!isset($this->all_recipients[strtolower(trim($address))])) {
|
||||
$this->bcc[] = array(trim($address), $name);
|
||||
$this->all_recipients[strtolower(trim($address))] = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -376,9 +388,7 @@ class PHPMailer {
|
|||
* @return void
|
||||
*/
|
||||
public function AddReplyTo($address, $name = '') {
|
||||
$cur = count($this->ReplyTo);
|
||||
$this->ReplyTo[$cur][0] = trim($address);
|
||||
$this->ReplyTo[$cur][1] = $name;
|
||||
$this->ReplyTo[] = array(trim($address), $name);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
|
|
@ -1171,6 +1181,15 @@ class PHPMailer {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all current attachments.
|
||||
* Needed for testability
|
||||
* @return array
|
||||
*/
|
||||
public function GetAttachments() {
|
||||
return $this->attachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches all fs, string, and binary attachments to the message.
|
||||
* Returns an empty string on failure.
|
||||
|
|
|
|||
Loading…
Reference in New Issue