Skip to content

Commit

Permalink
Minor fixes, code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Synchro committed Aug 31, 2016
1 parent abd34cb commit 1e53c07
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
6 changes: 2 additions & 4 deletions examples/code_generator.phps
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ try {
$example_code .= "\n\$mail->Host = \"" . $_POST['smtp_server'] . "\";";
$example_code .= "\n\$mail->Port = \"" . $_POST['smtp_port'] . "\";";
$example_code .= "\n\$mail->SMTPSecure = \"" . strtolower($_POST['smtp_secure']) . "\";";
$example_code .= "\n\$mail->SMTPAuth = " . (array_key_exists(
'smtp_authenticate',
$_POST
) ? 'true' : 'false') . ";";
$example_code .= "\n\$mail->SMTPAuth = " .
(array_key_exists('smtp_authenticate', $_POST) ? 'true' : 'false') . ";";
if (array_key_exists('smtp_authenticate', $_POST)) {
$example_code .= "\n\$mail->Username = \"" . $_POST['authenticate_username'] . "\";";
$example_code .= "\n\$mail->Password = \"" . $_POST['authenticate_password'] . "\";";
Expand Down
7 changes: 4 additions & 3 deletions examples/simple_contact_form.phps
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require '../vendor/autoload.php';
if (array_key_exists('to', $_POST)) {
$err = false;
$msg = '';
$email = '';
//Apply some basic validation and filtering to the subject
if (array_key_exists('subject', $_POST)) {
$subject = substr(strip_tags($_POST['subject']), 0, 255);
Expand Down Expand Up @@ -55,9 +56,9 @@ if (array_key_exists('to', $_POST)) {
$mail->Host = 'localhost';
$mail->Port = 2500;
$mail->CharSet = 'utf-8';
//It's important not to use the submitter's address as the form address as it's forgery,
//which will cause our messages to fail SPF checks
//Use an address in your own domain here
//It's important not to use the submitter's address as the from address as it's forgery,
//which will cause your messages to fail SPF checks.
//Use an address in your own domain as the from address, put the submitter's address in a reply-to
$mail->setFrom('contact@example.com', (empty($name)? 'Contact form': $name));
$mail->addAddress($to);
$mail->addReplyTo($email, $name);
Expand Down
3 changes: 2 additions & 1 deletion examples/smime_signed_mail.phps
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*
*
* STEP 1 - Creating a certificate:
* You can either use a self signed certificate, pay for a signed one or use free alternatives such as StartSSL/Comodo etc.
* You can either use a self-signed certificate, pay for a signed one,
* or use free alternatives such as StartSSL, Comodo etc.
* Check out this link for more providers: http://kb.mozillazine.org/Getting_an_SMIME_certificate
* In this example I am using Comodo.
* The form is directly available via https://secure.comodo.com/products/frontpage?area=SecureEmailCertificate
Expand Down
12 changes: 10 additions & 2 deletions get_oauth_token.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<a href='?provider=Yahoo'>Yahoo</a><br/>
<a href='?provider=Microsoft'>Microsoft/Outlook/Hotmail/Live/Office365</a><br/>
</body>
</html>
<?php
exit;
}
Expand All @@ -71,11 +72,12 @@
exit('Only Google, Microsoft and Yahoo OAuth2 providers are currently supported in this script.');
}

//These details obtained are by setting up app in Google developer console.
//These details are obtained by setting up an app in the Google developer console,
//or whichever provider you're using.
$clientId = 'RANDOMCHARS-----duv1n2.apps.googleusercontent.com';
$clientSecret = 'RANDOMCHARS-----lGyjPcRtvP';

//If this automatic URL doesn't work, set it yourself manually
//If this automatic URL doesn't work, set it yourself manually to the URL of this script
$redirectUri = (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
//$redirectUri = 'http://localhost/PHPMailer/redirect';

Expand All @@ -87,6 +89,7 @@
];

$options = [];
$provider = null;

switch ($providerName) {
case 'Google':
Expand All @@ -111,6 +114,11 @@
break;
}

if (is_null($provider)) {
echo 'Provider missing';
exit;
}

if (!isset($_GET['code'])) {
// If we don't have an authorization code then get one
$authUrl = $provider->getAuthorizationUrl($options);
Expand Down
3 changes: 2 additions & 1 deletion src/PHPMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,8 @@ public function punyencodeAddress($address)
if ($this->has8bitChars($domain) and @mb_check_encoding($domain, $this->CharSet)) {
$domain = mb_convert_encoding($domain, 'UTF-8', $this->CharSet);
//Ignore IDE complaints about this line - method signature changed in PHP 5.4
if (false !== ($punycode = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46))) {
$errorcode = 0;
if (false !== ($punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_UTS46))) {
return substr($address, 0, $pos) . $punycode;
}
}
Expand Down
16 changes: 8 additions & 8 deletions test/fakesendmail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
#Create a temp folder to put messages in
numPath="${TMPDIR-/tmp/}fakemail"
umask 037
mkdir -p $numPath
mkdir -p ${numPath}

if [ ! -f $numPath/num ]; then
echo "0" > $numPath/num
if [ ! -f ${numPath}/num ]; then
echo "0" > ${numPath}/num
fi
num=`cat $numPath/num`
num=$(($num + 1))
echo $num > $numPath/num
num=`cat ${numPath}/num`
num=$((${num} + 1))
echo ${num} > ${numPath}/num

name="$numPath/message_$num.eml"
name="${numPath}/message_${num}.eml"
while read line
do
echo $line >> $name
echo ${line} >> ${name}
done
exit 0

0 comments on commit 1e53c07

Please sign in to comment.