Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Email system #388

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -872,3 +872,48 @@ function slash_item($item)
}
}
//--------------------------------------------------------------------

if ( ! function_exists('function_usable'))
{
/**
* Function usable
*
* Executes a function_exists() check, and if the Suhosin PHP
* extension is loaded - checks whether the function that is
* checked might be disabled in there as well.
*
* This is useful as function_exists() will return FALSE for
* functions disabled via the *disable_functions* php.ini
* setting, but not for *suhosin.executor.func.blacklist* and
* *suhosin.executor.disable_eval*. These settings will just
* terminate script execution if a disabled function is executed.
*
* The above described behavior turned out to be a bug in Suhosin,
* but even though a fix was committed for 0.9.34 on 2012-02-12,
* that version is yet to be released. This function will therefore
* be just temporary, but would probably be kept for a few years.
*
* @link http://www.hardened-php.net/suhosin/
* @param string $functionName Function to check for
* @return bool TRUE if the function exists and is safe to call,
* FALSE otherwise.
*/
function function_usable($functionName)
{
static $suhosinFuncBlacklist;

if (function_exists($functionName))
{
if ( ! isset($suhosinFuncBlacklist))
{
$suhosinFuncBlacklist = extension_loaded('suhosin')
? explode(',', trim(ini_get('suhosin.executor.func.blacklist')))
: array();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

short array syntax

}

return ! in_array($functionName, $suhosinFuncBlacklist, true);
}

return false;
}
}
11 changes: 11 additions & 0 deletions system/Language/en/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,15 @@
'invalidEmail' => 'Invalid email address: %s',
'noFrom' => 'Cannot send mail with no "From" header.',
'noRecipients' => 'You must include recipients: To, Cc, or Bcc',
'sendFailurePhpmail' => 'Unable to send email using PHP mail(). Your server might not be configured to send mail using this method',
'sendFailureSendmail' => 'Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.',
'sendFailureSmtp' => 'Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.',
'sent' => 'Your message has been successfully sent using the following protocol: ',
'smtpError' => 'The following SMTP error was encountered: ',
'noSMTPUnpw' => 'Error: You must assign a SMTP username and password.',
'failedSMTPLogin' => 'Failed to send AUTH LOGIN command. Error: ',
'smtpAuthUn' => 'Failed to authenticate username. Error: ',
'smtpAuthPw' => 'Failed to authenticate password. Error: ',
'smtpDataFailure' => 'Unable to send data: ',
'exitStatus' => 'Exit status code: ',
];
28 changes: 26 additions & 2 deletions system/Mail/BaseMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ abstract class BaseMessage implements MessageInterface
protected $cc = [];
protected $bcc = [];
protected $subject;
protected $returnPath;

protected $messageHTML;
protected $messageText;
Expand Down Expand Up @@ -169,6 +170,20 @@ public function getFrom(): array

//--------------------------------------------------------------------

/**
* Returns the 'ReturnPath' portion, which is automatically set
* when setting the "from" value.
*
* @return string
*/
public function getReturnPath(): string
{
return ! empty($this->returnPath)
? $this->returnPath
: '';
}


/**
* Sets the name and email address of one person this is from.
* If this method is called multiple times, it adds multiple people
Expand All @@ -177,16 +192,25 @@ public function getFrom(): array
* @param string $email
* @param string|null $name
*
* @return self
* @param string $returnPath
*
* @return \CodeIgniter\Mail\BaseMessage
*/
public function setFrom(string $email, string $name=null)
public function setFrom(string $email, string $name=null, string $returnPath = null)
{
$recipient = is_null($name)
? [$email]
: [$name => $email];

$this->setRecipients($recipient, 'from');

if (empty($returnPath))
{
$returnPath = $email;
}

$this->returnPath = '<'.$returnPath.'>';

return $this;
}

Expand Down
Loading