Import 5.1
This commit is contained in:
parent
e2874ecc02
commit
5b661107ca
34
aboutus.html
34
aboutus.html
|
|
@ -65,7 +65,7 @@ some of our costs.<br />
|
|||
Thanks ....<br />
|
||||
<hr>
|
||||
<p>PHPMailer is the world's leading email transport class and downloaded an
|
||||
average of more than 26,000 each month. In March 2009, PHPMailer was downloaded
|
||||
average of more than 32,000 each month. In March 2009, PHPMailer was downloaded
|
||||
more than 31,000 times -- that's an average of 1,000 downloads daily. Our thanks
|
||||
to our new users and loyal users. We understand you have many choices available
|
||||
to select from and we thank you for select our fast and stable tool for your
|
||||
|
|
@ -93,7 +93,7 @@ in a project, please let us know about it.</p>
|
|||
<tr>
|
||||
<td width="50%" valign="top">
|
||||
<p><a href="http://www.codeworxtech.com">www.codeworxtech.com</a> for more information.<br>
|
||||
Web design, web applications, forms: <a href="http://www.worxstudio.com">WorxStudio.com</a><br />
|
||||
Web design, web applications, forms: <a href="http://www.worxstudio.com">WorxStudio.com</a><br />
|
||||
</p>
|
||||
<p>Our company, <strong>Worx International Inc.</strong>, is the publisher of several Open Source applications and developer tools as well as several commercial PHP applications. The Open Source applications are ttCMS and DCP Portal. The Open Source developer tools include QuickComponents (QuickSkin and QuickCache) and now PHPMailer.
|
||||
We have staff and offices in the United States, Caribbean, the Middle
|
||||
|
|
@ -104,15 +104,15 @@ in a project, please let us know about it.</p>
|
|||
<p>Our developer tools are all Open Source. Here's a brief description:</p>
|
||||
<ul>
|
||||
<li><span style="background-color: #FFFF00"><strong>PHPMailer</strong></span>. Originally authored by Brent Matzelle, PHPMailer is the leading "email transfer class" for PHP. PHPMailer is downloaded more than
|
||||
26000 times each and every month by developers looking for a fast, stable, simple email solution. We used it ourselves for years as our favorite tool. It's always been small (the entire footprint is
|
||||
less than 100 Kb), stable, and as complete a solution as you can find.
|
||||
Other tools are nowhere near as simple. Our thanks to Brent Matzelle for this superb tool - our commitment is to keep it lean, keep it focused, and compliant with standards. Visit the PHPMailer website at
|
||||
26000 times each and every month by developers looking for a fast, stable, simple email solution. We used it ourselves for years as our favorite tool. It's always been small (the entire footprint is
|
||||
less than 100 Kb), stable, and as complete a solution as you can find.
|
||||
Other tools are nowhere near as simple. Our thanks to Brent Matzelle for this superb tool - our commitment is to keep it lean, keep it focused, and compliant with standards. Visit the PHPMailer website at
|
||||
<a href="http://phpmailer.codeworxtech.com/">http://phpmailer.codeworxtech.com/</a>. <br />
|
||||
Please note: <strong>all of our focus is now on the PHPMailer for PHP5.</strong><br />
|
||||
<span style="background-color: #FFFF00">PS. While you are at it, please visit our sponsor's sites, click on their ads.
|
||||
It helps offset some of our costs.</span><br />
|
||||
Want to help? We're looking for progressive developers to join our team of volunteer professionals working on PHPMailer. Our entire focus is on PHPMailer
|
||||
for PHP5. If you are interested, let us know.<br />
|
||||
for PHP5. If you are interested, let us know.<br />
|
||||
<br />
|
||||
</li>
|
||||
<li><strong><span style="background-color: #FFFF00">QuickCache</span></strong>. Originally authored by Jean Pierre Deckers as jpCache, QuickCache is an HTTP OpCode caching strategy that works on your entire site with only one line of code at the top of your script. The cached pages can be stored as files or as database objects. The benefits are absolutely astounding: bandwidth savings of up to 80% and screen display times increased by 8 - 10x. Visit the QuickCache website at
|
||||
|
|
@ -149,18 +149,18 @@ in a project, please let us know about it.</p>
|
|||
We now also offer website design. hosting, and remote forms processing. Visit <a href="http://www.worxstudio.com/" target="_blank">WorxStudio.com</a> for more information.<br />
|
||||
</td>
|
||||
<td width="50%" valign="top">
|
||||
<p>Marcus is the technical director of <a href="http://www.synchromedia.co.uk/">Synchromedia Limited</a>, a UK-based company providing online business services. Synchromedia's main services are:</p>
|
||||
<p>Marcus is the technical director of <a href="http://www.synchromedia.co.uk/">Synchromedia Limited</a>, a UK-based company providing online business services. Synchromedia's main services are:</p>
|
||||
<h2>Smartmessages.net</h2>
|
||||
<p><a href="https://www.smartmessages.net/"><img src="http://www.synchromedia.co.uk/uploads/images/smlogo.gif" width="292" height="48" alt="Smartmessages.net logo" /><br />Smartmessages.net</a> is Synchromedia's large-scale mailing list management system, providing email delivery services for a wide range of businesses, from sole traders to corporates.
|
||||
We pride ourselves on personal service, and realise that every one of your subscribers is a precious asset to be handled with care.
|
||||
We provide fast, reliable, high-volume delivery (some of our customers have lists of more than 1,000,000 subscribers) with fine-grained tracking while ensuring you stay fully compliant with UK, EC and US data protection laws. Smartmessages of course uses PHPMailer at its heart!</p>
|
||||
<h2>info@hand</h2>
|
||||
<p><a href="http://www.synchromedia.co.uk/what-we-do/info-at-hand-crm/"><img src="http://www.synchromedia.co.uk/uploads/images/infoathand-large.png" width="250" height="40" alt="info@hand logo" /></a><br />Synchromedia is the official UK distributor of <a href="http://www.thelongreach.com/">info@hand</a>, a class-leading open-source web-based CRM system. We provide licenses, hosting, planning, support and training for this very fully-featured system at very competitive prices. info@hand also uses PHPMailer!</p>
|
||||
<h2>How can we help you?</h2>
|
||||
<p>In addition to our headline services, we also provide consulting, development, hosting and sysadmin services, so if you just need a simple web hosting package, we can do that too. Not surprisingly, we know rather a lot about email, so you can talk to us about that too.</p>
|
||||
<p>Please <a href="http://www.synchromedia.co.uk/about-us/contact-us/">contact us</a> if you'd like to know more.</p>
|
||||
<p>Marcus is a regular attendee at <a href="http://www.phplondon.org/">PHP London</a>, and occasionally speaks on email at technical conferences.</p>
|
||||
</td>
|
||||
<p><a href="https://www.smartmessages.net/"><img src="http://www.synchromedia.co.uk/uploads/images/smlogo.gif" width="292" height="48" alt="Smartmessages.net logo" /><br />Smartmessages.net</a> is Synchromedia's large-scale mailing list management system, providing email delivery services for a wide range of businesses, from sole traders to corporates.
|
||||
We pride ourselves on personal service, and realise that every one of your subscribers is a precious asset to be handled with care.
|
||||
We provide fast, reliable, high-volume delivery (some of our customers have lists of more than 1,000,000 subscribers) with fine-grained tracking while ensuring you stay fully compliant with UK, EC and US data protection laws. Smartmessages of course uses PHPMailer at its heart!</p>
|
||||
<h2>info@hand</h2>
|
||||
<p><a href="http://www.synchromedia.co.uk/what-we-do/info-at-hand-crm/"><img src="http://www.synchromedia.co.uk/uploads/images/infoathand-large.png" width="250" height="40" alt="info@hand logo" /></a><br />Synchromedia is the official UK distributor of <a href="http://www.thelongreach.com/">info@hand</a>, a class-leading open-source web-based CRM system. We provide licenses, hosting, planning, support and training for this very fully-featured system at very competitive prices. info@hand also uses PHPMailer!</p>
|
||||
<h2>How can we help you?</h2>
|
||||
<p>In addition to our headline services, we also provide consulting, development, hosting and sysadmin services, so if you just need a simple web hosting package, we can do that too. Not surprisingly, we know rather a lot about email, so you can talk to us about that too.</p>
|
||||
<p>Please <a href="http://www.synchromedia.co.uk/about-us/contact-us/">contact us</a> if you'd like to know more.</p>
|
||||
<p>Marcus is a regular attendee at <a href="http://www.phplondon.org/">PHP London</a>, and occasionally speaks on email at technical conferences.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,31 @@ ChangeLog
|
|||
NOTE: THIS VERSION OF PHPMAILER IS DESIGNED FOR PHP5/PHP6.
|
||||
IT WILL NOT WORK WITH PHP4.
|
||||
|
||||
Version 5.1 (October 20, 2009)
|
||||
* fixed filename issue with AddStringAttachment (thanks to Tony)
|
||||
* fixed "SingleTo" property, now works with Senmail, Qmail, and SMTP in
|
||||
addition to PHP mail()
|
||||
* added DKIM digital signing functionality
|
||||
New properties:
|
||||
- DKIM_domain (sets the domain name)
|
||||
- DKIM_private (holds DKIM private key)
|
||||
- DKIM_passphrase (holds your DKIM passphrase)
|
||||
- DKIM_selector (holds the DKIM "selector")
|
||||
- DKIM_identity (holds the identifying email address)
|
||||
* added callback function support
|
||||
- callback function parameters include:
|
||||
result, to, cc, bcc, subject and body
|
||||
* see the test/test_callback.php file for usage.
|
||||
* added "auto" identity functionality
|
||||
- can automatically add:
|
||||
- Return-path (if Sender not set)
|
||||
- Reply-To (if ReplyTo not set)
|
||||
- can be disabled:
|
||||
- $mail->SetFrom('yourname@yourdomain.com','First Last',false);
|
||||
- or by adding the $mail->Sender and/or $mail->ReplyTo properties
|
||||
Note: "auto" identity added to help with emails ending up in spam
|
||||
or junk boxes because of missing headers
|
||||
|
||||
Version 5.0.2 (May 24, 2009)
|
||||
* Fix for missing attachments when inline graphics are present
|
||||
* Fix for missing Cc in header when using SMTP (mail was sent,
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
/*~ class.phpmailer.php
|
||||
.---------------------------------------------------------------------------.
|
||||
| Software: PHPMailer - PHP email class |
|
||||
| Version: 5.0.2 |
|
||||
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
|
||||
| Version: 5.1 |
|
||||
| Contact: via sourceforge.net support pages (also www.worxware.com) |
|
||||
| Info: http://phpmailer.sourceforge.net |
|
||||
| Support: http://sourceforge.net/projects/phpmailer/ |
|
||||
| ------------------------------------------------------------------------- |
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
||||
| FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| We offer a number of paid services (www.codeworxtech.com): |
|
||||
| We offer a number of paid services (www.worxware.com): |
|
||||
| - Web Hosting on highly optimized fast and secure servers |
|
||||
| - Technology Consulting |
|
||||
| - Oursourcing (highly qualified programmers and graphic designers) |
|
||||
|
|
@ -244,17 +244,63 @@ class PHPMailer {
|
|||
*/
|
||||
public $SingleTo = false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* If SingleTo is true, this provides the array to hold the email addresses
|
||||
* @var bool
|
||||
*/
|
||||
public $SingleToArray = array();
|
||||
|
||||
/**
|
||||
* Provides the ability to change the line ending
|
||||
* @var string
|
||||
*/
|
||||
public $LE = "\n";
|
||||
|
||||
/**
|
||||
* Used with DKIM DNS Resource Record
|
||||
* @var string
|
||||
*/
|
||||
public $DKIM_selector = 'phpmailer';
|
||||
|
||||
/**
|
||||
* Used with DKIM DNS Resource Record
|
||||
* optional, in format of email address 'you@yourdomain.com'
|
||||
* @var string
|
||||
*/
|
||||
public $DKIM_identity = '';
|
||||
|
||||
/**
|
||||
* Used with DKIM DNS Resource Record
|
||||
* optional, in format of email address 'you@yourdomain.com'
|
||||
* @var string
|
||||
*/
|
||||
public $DKIM_domain = '';
|
||||
|
||||
/**
|
||||
* Used with DKIM DNS Resource Record
|
||||
* optional, in format of email address 'you@yourdomain.com'
|
||||
* @var string
|
||||
*/
|
||||
public $DKIM_private = '';
|
||||
|
||||
/**
|
||||
* Callback Action function name
|
||||
* the function that handles the result of the send email action. Parameters:
|
||||
* bool $result result of the send action
|
||||
* string $to email address of the recipient
|
||||
* string $cc cc email addresses
|
||||
* string $bcc bcc email addresses
|
||||
* string $subject the subject
|
||||
* string $body the email body
|
||||
* @var string
|
||||
*/
|
||||
public $action_function = ''; //'callbackAction';
|
||||
|
||||
/**
|
||||
* Sets the PHPMailer Version number
|
||||
* @var string
|
||||
*/
|
||||
public $Version = '5.0.2';
|
||||
public $Version = '5.1';
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// PROPERTIES, PRIVATE AND PROTECTED
|
||||
|
|
@ -281,7 +327,7 @@ class PHPMailer {
|
|||
// CONSTANTS
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
const STOP_MESSAGE = 0; // message only, continue processing
|
||||
const STOP_MESSAGE = 0; // message only, continue processing
|
||||
const STOP_CONTINUE = 1; // message?, likely ok to continue processing
|
||||
const STOP_CRITICAL = 2; // message, plus full stop, critical error reached
|
||||
|
||||
|
|
@ -418,20 +464,20 @@ class PHPMailer {
|
|||
echo $this->Lang('invalid_address').': '.$address;
|
||||
return false;
|
||||
}
|
||||
if ($kind != 'ReplyTo') {
|
||||
if (!isset($this->all_recipients[strtolower($address)])) {
|
||||
if ($kind != 'ReplyTo') {
|
||||
if (!isset($this->all_recipients[strtolower($address)])) {
|
||||
array_push($this->$kind, array($address, $name));
|
||||
$this->all_recipients[strtolower($address)] = true;
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
|
||||
} else {
|
||||
if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
|
||||
$this->ReplyTo[strtolower($address)] = array($address, $name);
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the From and FromName properties
|
||||
|
|
@ -439,7 +485,7 @@ class PHPMailer {
|
|||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
public function SetFrom($address, $name = '') {
|
||||
public function SetFrom($address, $name = '',$auto=1) {
|
||||
$address = trim($address);
|
||||
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
|
||||
if (!self::ValidateAddress($address)) {
|
||||
|
|
@ -450,9 +496,17 @@ class PHPMailer {
|
|||
echo $this->Lang('invalid_address').': '.$address;
|
||||
return false;
|
||||
}
|
||||
$this->From = $address;
|
||||
$this->FromName = $name;
|
||||
return true;
|
||||
$this->From = $address;
|
||||
$this->FromName = $name;
|
||||
if ($auto) {
|
||||
if (empty($this->ReplyTo)) {
|
||||
$this->AddAnAddress('ReplyTo', $address, $name);
|
||||
}
|
||||
if (empty($this->Sender)) {
|
||||
$this->Sender = $address;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -508,13 +562,18 @@ class PHPMailer {
|
|||
throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL);
|
||||
}
|
||||
|
||||
// digitally sign with DKIM if enabled
|
||||
if ($this->DKIM_domain && $this->DKIM_private) {
|
||||
$header_dkim = $this->DKIM_Add($header,$this->Subject,$body);
|
||||
$header = str_replace("\r\n","\n",$header_dkim) . $header;
|
||||
}
|
||||
|
||||
// Choose the mailer and send through it
|
||||
switch($this->Mailer) {
|
||||
case 'sendmail':
|
||||
return $this->SendmailSend($header, $body);
|
||||
case 'smtp':
|
||||
return $this->SmtpSend($header, $body);
|
||||
case 'mail':
|
||||
default:
|
||||
return $this->MailSend($header, $body);
|
||||
}
|
||||
|
|
@ -542,14 +601,35 @@ class PHPMailer {
|
|||
} else {
|
||||
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
|
||||
}
|
||||
if(!@$mail = popen($sendmail, 'w')) {
|
||||
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
|
||||
}
|
||||
fputs($mail, $header);
|
||||
fputs($mail, $body);
|
||||
$result = pclose($mail);
|
||||
if($result != 0) {
|
||||
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
|
||||
if ($this->SingleTo === true) {
|
||||
foreach ($this->SingleToArray as $key => $val) {
|
||||
if(!@$mail = popen($sendmail, 'w')) {
|
||||
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
|
||||
}
|
||||
fputs($mail, "To: " . $val . "\n");
|
||||
fputs($mail, $header);
|
||||
fputs($mail, $body);
|
||||
$result = pclose($mail);
|
||||
// implement call back function if it exists
|
||||
$isSent = ($result == 0) ? 1 : 0;
|
||||
$this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
|
||||
if($result != 0) {
|
||||
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!@$mail = popen($sendmail, 'w')) {
|
||||
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
|
||||
}
|
||||
fputs($mail, $header);
|
||||
fputs($mail, $body);
|
||||
$result = pclose($mail);
|
||||
// implement call back function if it exists
|
||||
$isSent = ($result == 0) ? 1 : 0;
|
||||
$this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
|
||||
if($result != 0) {
|
||||
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -575,17 +655,29 @@ class PHPMailer {
|
|||
if ($this->SingleTo === true && count($toArr) > 1) {
|
||||
foreach ($toArr as $key => $val) {
|
||||
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
|
||||
// implement call back function if it exists
|
||||
$isSent = ($rt == 1) ? 1 : 0;
|
||||
$this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
|
||||
}
|
||||
} else {
|
||||
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
|
||||
// implement call back function if it exists
|
||||
$isSent = ($rt == 1) ? 1 : 0;
|
||||
$this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
|
||||
}
|
||||
} else {
|
||||
if ($this->SingleTo === true && count($toArr) > 1) {
|
||||
foreach ($toArr as $key => $val) {
|
||||
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
|
||||
// implement call back function if it exists
|
||||
$isSent = ($rt == 1) ? 1 : 0;
|
||||
$this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
|
||||
}
|
||||
} else {
|
||||
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
|
||||
// implement call back function if it exists
|
||||
$isSent = ($rt == 1) ? 1 : 0;
|
||||
$this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
|
||||
}
|
||||
}
|
||||
if (isset($old_from)) {
|
||||
|
|
@ -622,18 +714,41 @@ class PHPMailer {
|
|||
foreach($this->to as $to) {
|
||||
if (!$this->smtp->Recipient($to[0])) {
|
||||
$bad_rcpt[] = $to[0];
|
||||
// implement call back function if it exists
|
||||
$isSent = 0;
|
||||
$this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
|
||||
} else {
|
||||
// implement call back function if it exists
|
||||
$isSent = 1;
|
||||
$this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
|
||||
}
|
||||
}
|
||||
foreach($this->cc as $cc) {
|
||||
if (!$this->smtp->Recipient($cc[0])) {
|
||||
$bad_rcpt[] = $cc[0];
|
||||
// implement call back function if it exists
|
||||
$isSent = 0;
|
||||
$this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
|
||||
} else {
|
||||
// implement call back function if it exists
|
||||
$isSent = 1;
|
||||
$this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
|
||||
}
|
||||
}
|
||||
foreach($this->bcc as $bcc) {
|
||||
if (!$this->smtp->Recipient($bcc[0])) {
|
||||
$bad_rcpt[] = $bcc[0];
|
||||
// implement call back function if it exists
|
||||
$isSent = 0;
|
||||
$this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
|
||||
} else {
|
||||
// implement call back function if it exists
|
||||
$isSent = 1;
|
||||
$this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
|
||||
$badaddresses = implode(', ', $bad_rcpt);
|
||||
throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
|
||||
|
|
@ -972,10 +1087,16 @@ class PHPMailer {
|
|||
|
||||
// To be created automatically by mail()
|
||||
if($this->Mailer != 'mail') {
|
||||
if(count($this->to) > 0) {
|
||||
$result .= $this->AddrAppend('To', $this->to);
|
||||
} elseif (count($this->cc) == 0) {
|
||||
$result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
|
||||
if ($this->SingleTo === true) {
|
||||
foreach($this->to as $t) {
|
||||
$this->SingleToArray[] = $this->AddrFormat($t);
|
||||
}
|
||||
} else {
|
||||
if(count($this->to) > 0) {
|
||||
$result .= $this->AddrAppend('To', $this->to);
|
||||
} elseif (count($this->cc) == 0) {
|
||||
$result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1009,7 +1130,7 @@ class PHPMailer {
|
|||
$result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
|
||||
}
|
||||
$result .= $this->HeaderLine('X-Priority', $this->Priority);
|
||||
$result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.codeworxtech.com)');
|
||||
$result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)');
|
||||
|
||||
if($this->ConfirmReadingTo != '') {
|
||||
$result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
|
||||
|
|
@ -1637,7 +1758,7 @@ class PHPMailer {
|
|||
$this->attachment[] = array(
|
||||
0 => $string,
|
||||
1 => $filename,
|
||||
2 => $filename,
|
||||
2 => basename($filename),
|
||||
3 => $encoding,
|
||||
4 => $type,
|
||||
5 => true, // isStringAttachment
|
||||
|
|
@ -2062,6 +2183,132 @@ class PHPMailer {
|
|||
$this->sign_key_file = $key_filename;
|
||||
$this->sign_key_pass = $key_pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the private key file and password to sign the message.
|
||||
*
|
||||
* @access public
|
||||
* @param string $key_filename Parameter File Name
|
||||
* @param string $key_pass Password for private key
|
||||
*/
|
||||
public function DKIM_QP($txt) {
|
||||
$tmp="";
|
||||
$line="";
|
||||
for ($i=0;$i<strlen($txt);$i++) {
|
||||
$ord=ord($txt[$i]);
|
||||
if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
|
||||
$line.=$txt[$i];
|
||||
} else {
|
||||
$line.="=".sprintf("%02X",$ord);
|
||||
}
|
||||
}
|
||||
return $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate DKIM signature
|
||||
*
|
||||
* @access public
|
||||
* @param string $s Header
|
||||
*/
|
||||
public function DKIM_Sign($s) {
|
||||
$privKeyStr = file_get_contents($this->DKIM_private);
|
||||
if ($this->DKIM_passphrase!='') {
|
||||
$privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
|
||||
} else {
|
||||
$privKey = $privKeyStr;
|
||||
}
|
||||
if (openssl_sign($s, $signature, $privKey)) {
|
||||
return base64_encode($signature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate DKIM Canonicalization Header
|
||||
*
|
||||
* @access public
|
||||
* @param string $s Header
|
||||
*/
|
||||
public function DKIM_HeaderC($s) {
|
||||
$s=preg_replace("/\r\n\s+/"," ",$s);
|
||||
$lines=explode("\r\n",$s);
|
||||
foreach ($lines as $key=>$line) {
|
||||
list($heading,$value)=explode(":",$line,2);
|
||||
$heading=strtolower($heading);
|
||||
$value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces
|
||||
$lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value
|
||||
}
|
||||
$s=implode("\r\n",$lines);
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate DKIM Canonicalization Body
|
||||
*
|
||||
* @access public
|
||||
* @param string $body Message Body
|
||||
*/
|
||||
public function DKIM_BodyC($body) {
|
||||
if ($body == '') return "\r\n";
|
||||
// stabilize line endings
|
||||
$body=str_replace("\r\n","\n",$body);
|
||||
$body=str_replace("\n","\r\n",$body);
|
||||
// END stabilize line endings
|
||||
while (substr($body,strlen($body)-4,4) == "\r\n\r\n") {
|
||||
$body=substr($body,0,strlen($body)-2);
|
||||
}
|
||||
return $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the DKIM header, body, as new header
|
||||
*
|
||||
* @access public
|
||||
* @param string $headers_line Header lines
|
||||
* @param string $subject Subject
|
||||
* @param string $body Body
|
||||
*/
|
||||
public function DKIM_Add($headers_line,$subject,$body) {
|
||||
$DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms
|
||||
$DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
|
||||
$DKIMquery = 'dns/txt'; // Query method
|
||||
$DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
|
||||
$subject_header = "Subject: $subject";
|
||||
$headers = explode("\r\n",$headers_line);
|
||||
foreach($headers as $header) {
|
||||
if (strpos($header,'From:') === 0) {
|
||||
$from_header=$header;
|
||||
} elseif (strpos($header,'To:') === 0) {
|
||||
$to_header=$header;
|
||||
}
|
||||
}
|
||||
$from = str_replace('|','=7C',$this->DKIM_QP($from_header));
|
||||
$to = str_replace('|','=7C',$this->DKIM_QP($to_header));
|
||||
$subject = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable
|
||||
$body = $this->DKIM_BodyC($body);
|
||||
$DKIMlen = strlen($body) ; // Length of body
|
||||
$DKIMb64 = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body
|
||||
$ident = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";";
|
||||
$dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n".
|
||||
"\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n".
|
||||
"\th=From:To:Subject;\r\n".
|
||||
"\td=" . $this->DKIM_domain . ";" . $ident . "\r\n".
|
||||
"\tz=$from\r\n".
|
||||
"\t|$to\r\n".
|
||||
"\t|$subject;\r\n".
|
||||
"\tbh=" . $DKIMb64 . ";\r\n".
|
||||
"\tb=";
|
||||
$toSign = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
|
||||
$signed = $this->DKIM_Sign($toSign);
|
||||
return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n";
|
||||
}
|
||||
|
||||
protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) {
|
||||
if (!empty($this->action_function) && function_exists($this->action_function)) {
|
||||
$params = array($isSent,$to,$cc,$bcc,$subject,$body);
|
||||
call_user_func_array($this->action_function,$params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class phpmailerException extends Exception {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/*~ class.pop3.php
|
||||
.---------------------------------------------------------------------------.
|
||||
| Software: PHPMailer - PHP email class |
|
||||
| Version: 5.0.0 |
|
||||
| Version: 5.1 |
|
||||
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
|
||||
| Info: http://phpmailer.sourceforge.net |
|
||||
| Support: http://sourceforge.net/projects/phpmailer/ |
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/*~ class.smtp.php
|
||||
.---------------------------------------------------------------------------.
|
||||
| Software: PHPMailer - PHP email class |
|
||||
| Version: 5.0.0 |
|
||||
| Version: 5.1 |
|
||||
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
|
||||
| Info: http://phpmailer.sourceforge.net |
|
||||
| Support: http://sourceforge.net/projects/phpmailer/ |
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>PHPMailer Lite - DKIM and Callback Function test</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
/* This is a sample callback function for PHPMailer Lite.
|
||||
* This callback function will echo the results of PHPMailer processing.
|
||||
*/
|
||||
|
||||
/* Callback (action) function
|
||||
* bool $result result of the send action
|
||||
* string $to email address of the recipient
|
||||
* string $cc cc email addresses
|
||||
* string $bcc bcc email addresses
|
||||
* string $subject the subject
|
||||
* string $body the email body
|
||||
* @return boolean
|
||||
*/
|
||||
function callbackAction ($result, $to, $cc, $bcc, $subject, $body) {
|
||||
/*
|
||||
this callback example echos the results to the screen - implement to
|
||||
post to databases, build CSV log files, etc., with minor changes
|
||||
*/
|
||||
$to = cleanEmails($to,'to');
|
||||
$cc = cleanEmails($cc[0],'cc');
|
||||
$bcc = cleanEmails($bcc[0],'cc');
|
||||
echo $result . "\tTo: " . $to['Name'] . "\tTo: " . $to['Email'] . "\tCc: " . $cc['Name'] . "\tCc: " . $cc['Email'] . "\tBcc: " . $bcc['Name'] . "\tBcc: " . $bcc['Email'] . "\t" . $subject . "<br />\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
$testLite = false;
|
||||
|
||||
if ($testLite) {
|
||||
require_once '../class.phpmailer-lite.php';
|
||||
$mail = new PHPMailerLite();
|
||||
} else {
|
||||
require_once '../class.phpmailer.php';
|
||||
$mail = new PHPMailer();
|
||||
}
|
||||
|
||||
try {
|
||||
$mail->IsMail(); // telling the class to use SMTP
|
||||
$mail->SetFrom('you@yourdomain.com', 'Your Name');
|
||||
$mail->AddAddress('another@yourdomain.com', 'John Doe');
|
||||
$mail->Subject = 'PHPMailer Lite Test Subject via Mail()';
|
||||
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
|
||||
$mail->MsgHTML(file_get_contents('contents.html'));
|
||||
$mail->AddAttachment('images/phpmailer.gif'); // attachment
|
||||
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
|
||||
$mail->action_function = 'callbackAction';
|
||||
$mail->Send();
|
||||
echo "Message Sent OK</p>\n";
|
||||
} catch (phpmailerException $e) {
|
||||
echo $e->errorMessage(); //Pretty error messages from PHPMailer
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage(); //Boring error messages from anything else!
|
||||
}
|
||||
|
||||
function cleanEmails($str,$type) {
|
||||
if ($type == 'cc') {
|
||||
$addy['Email'] = $str[0];
|
||||
$addy['Name'] = $str[1];
|
||||
return $addy;
|
||||
}
|
||||
if (!strstr($str, ' <')) {
|
||||
$addy['Name'] = '';
|
||||
$addy['Email'] = $addy;
|
||||
return $addy;
|
||||
}
|
||||
$addyArr = explode(' <', $str);
|
||||
if (substr($addyArr[1],-1) == '>') {
|
||||
$addyArr[1] = substr($addyArr[1],0,-1);
|
||||
}
|
||||
$addy['Name'] = $addyArr[0];
|
||||
$addy['Email'] = $addyArr[1];
|
||||
$addy['Email'] = str_replace('@', '@', $addy['Email']);
|
||||
return $addy;
|
||||
}
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue