### Manual Installation of Rules Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpstan/phpstan-strict-rules/README.md Include the rules.neon file in your PHPStan configuration if not using the extension installer. ```neon includes: - vendor/phpstan/phpstan-strict-rules/rules.neon ``` -------------------------------- ### Basic Email Sending with PHPMailer Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/README.md This example demonstrates how to send an email using PHPMailer with SMTP authentication, including setting recipients, CC/BCC, attachments, and HTML content. Ensure you have PHPMailer installed via Composer or included in your include_path. ```php IsSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'jswan'; // SMTP username $mail->Password = 'secret'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted $mail->From = 'from@example.com'; $mail->FromName = 'Mailer'; $mail->AddAddress('josh@example.net', 'Josh Adams'); // Add a recipient $mail->AddAddress('ellen@example.com'); // Name is optional $mail->AddReplyTo('info@example.com', 'Information'); $mail->AddCC('cc@example.com'); $mail->AddBCC('bcc@example.com'); $mail->WordWrap = 50; // Set word wrap to 50 characters $mail->AddAttachment('/var/tmp/file.tar.gz'); // Add attachments $mail->AddAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name $mail->IsHTML(true); // Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body in bold!'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; if(!$mail->Send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; exit; } echo 'Message has been sent'; ``` -------------------------------- ### Install phpstan/phpstan-strict-rules with Composer Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpstan/phpstan-strict-rules/README.md Install the strict rules package using Composer for development dependencies. ```bash composer require --dev phpstan/phpstan-strict-rules ``` -------------------------------- ### Basic TypeScript Function Example Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/test_script/test.html A simple function declaration in TypeScript. Note the type annotation for the return value. ```typescript function test() : String { return 10; } ``` -------------------------------- ### Initialize SyntaxHighlighter Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/test_script/test.html Call this function to apply SyntaxHighlighter to all code blocks on the page. ```javascript SyntaxHighlighter.all(); ``` -------------------------------- ### Include PHPMailer and POP3 Classes Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/docs/pop3_article.txt Include the necessary PHPMailer and POP3 class files before using them. Ensure the paths are correct relative to your project structure. ```php require 'phpmailer-1.72/class.phpmailer.php'; require 'phpmailer-1.72/class.pop3.php'; ``` -------------------------------- ### Use Custom Extended PHPMailer Class Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/docs/extending.html Demonstrates how to instantiate and use a custom PHPMailer class that has been extended with specific default configurations. ```php require("mail.inc.php"); // Instantiate your new class $mail = new my_phpmailer; // Now you only need to add the necessary stuff $mail->AddAddress("josh@example.com", "Josh Adams"); $mail->Subject = "Here is the subject"; $mail->Body = "This is the message body"; $mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip"); // optional name if(!$mail->Send()) { echo "There was an error sending the message"; exit; } echo "Message was sent successfully"; ``` -------------------------------- ### Generate and Run Dependabot Tests Source: https://github.com/dependabot/smoke-tests/blob/main/README.md Commands to generate a test file from updates and execute tests using the CLI. ```console dependabot update go_modules dependabot/smoke-tests -o my-test.yml ``` ```console dependabot test -f my-test.yml ``` -------------------------------- ### Configure registry credentials with environment variables Source: https://github.com/dependabot/smoke-tests/blob/main/README.md Use environment variables within the credentials configuration to avoid hardcoding sensitive tokens in test files. ```yaml credentials: - type: npm_registry registry: https://npm.pkg.github.com token: $MY_TOKEN ``` -------------------------------- ### Configure SyntaxHighlighter Clipboard SWF Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/test_script/test.html Set the path to the clipboard SWF file for SyntaxHighlighter's copy-to-clipboard functionality. ```javascript SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf'; ``` -------------------------------- ### POP3 Authorize Method Parameters Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/docs/pop3_article.txt Details the parameters required for the POP3 Authorise method. These include server details, credentials, and debug level. ```php $pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1); ``` -------------------------------- ### Send Multiple Emails with Attachments from Database Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/docs/extending.html Demonstrates sending multiple emails with HTML and plain text bodies, binary attachments, and multipart/alternative support, fetching recipient data from a MySQL database. ```php require("class.phpmailer.php"); $mail = new phpmailer(); $mail->From = "list@example.com"; $mail->FromName = "List manager"; $mail->Host = "smtp1.example.com;smtp2.example.com"; $mail->Mailer = "smtp"; @MYSQL_CONNECT("localhost","root","password"); @mysql_select_db("my_company"); $query ="SELECT full_name, email,photoFROM employeeWHEREid=$id"; $result=@MYSQL_QUERY($query); while ($row = mysql_fetch_array ($result)) { // HTML body $body = "Hello " . $row["full_name"] . ",
"; $body .= "Your personal photograph to this message.
";
$body .= "Sincerely,
";
$body .= "phpmailer List manager";
// Plain text body (for mail clients that cannot read HTML)
$text_body = "Hello " . $row["full_name"] . ", \n\n";
$text_body .= "Your personal photograph to this message.\n\n";
$text_body .= "Sincerely, \n";
$text_body .= "phpmailer List manager";
$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($row["email"], $row["full_name"]);
$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
if(!$mail->Send())
echo "There has been a mail error sending to " . $row["email"] . "
";
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
```
--------------------------------
### Regenerate smoke tests locally
Source: https://github.com/dependabot/smoke-tests/blob/main/README.md
Use the script/regen.sh utility to regenerate smoke test files, optionally using custom updater images or local dependabot-core checkouts.
```console
# Basic usage — regenerate with the released CLI
script/regen.sh tests/smoke-bundler.yaml
# Regenerate everything (e.g. after a breaking change in dependabot-core)
script/regen.sh tests/smoke-*.yaml
# Use a pre-built updater image
script/regen.sh --updater-image my-image:latest tests/smoke-bundler.yaml
# Build the updater from a local dependabot-core checkout
script/regen.sh --local-core ../dependabot-core tests/smoke-python-pip.yaml
# Build the updater from a dependabot-core PR
script/regen.sh --core-pr 12345 tests/smoke-python-pip.yaml tests/smoke-python-pip-compile.yaml
```
--------------------------------
### Extend PHPMailer Class with Custom Defaults
Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/docs/extending.html
Shows how to extend the PHPMailer class to create a custom mailer with predefined default settings and custom error handling.
```php
require("class.phpmailer.php");
class my_phpmailer extends phpmailer {
// Set default variables for all new objects
var $From = "from@example.com";
var $FromName = "Mailer";
var $Host = "smtp1.example.com;smtp2.example.com";
var $Mailer = "smtp"; // Alternative to IsSMTP()
var $WordWrap = 75;
// Replace the default error_handler
function error_handler($msg) {
print("My Site Error");
print("Description:");
printf("%s", $msg);
exit;
}
// Create an additional function
function do_something($something) {
// Place your new code here
}
}
```
--------------------------------
### Enable Specific Strict Rules
Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpstan/phpstan-strict-rules/README.md
Re-enable individual strict rules by setting their specific parameter to true after disabling all rules.
```neon
parameters:
strictRules:
allRules: false
booleansInConditions: true
```
--------------------------------
### POP3 Before SMTP Authentication and Email Sending
Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/docs/pop3_article.txt
This snippet demonstrates how to perform POP3 authentication before sending an email using PHPMailer. It includes connection parameters for the POP3 server and PHPMailer configuration.
```php
$pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);
$mail = new PHPMailer();
$mail->SMTPDebug = 2;
$mail->IsSMTP();
$mail->IsHTML(false);
$mail->Host = 'relay.example.com';
$mail->From = 'mailer@example.com';
$mail->FromName = 'Example Mailer';
$mail->Subject = 'My subject';
$mail->Body = 'Hello world';
$mail->AddAddress('rich@corephp.co.uk', 'Richard Davey');
if (!$mail->Send()) {
echo $mail->ErrorInfo;
}
```
--------------------------------
### Debug Test Failures
Source: https://github.com/dependabot/smoke-tests/blob/main/README.md
Commands to compare test outputs or overwrite existing test files to identify failures.
```console
dependabot test -f input.yml -o output.yml
diff input.yml output.yml
```
```console
dependabot test -f test.yml -o test.yml
```
--------------------------------
### Disable All Strict Rules
Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpstan/phpstan-strict-rules/README.md
Configure PHPStan to disable all strict rules by setting 'allRules' to false in the parameters.
```neon
parameters:
strictRules:
allRules: false
```
--------------------------------
### Enable SMTP Debugging in PHPMailer
Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/examples/index.html
Insert this after $mail->IsSMTP(); to enable SMTP debug information for testing. A setting of 2 will display all errors and messages generated by the SMTP server.
```php
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
```
--------------------------------
### Secure DKIM Private Key with .htaccess
Source: https://github.com/dependabot/smoke-tests/blob/main/composer/vendor/phpmailer/phpmailer/docs/DomainKeys_notes.txt
Protect your DKIM private key file from unauthorized access by configuring your .htaccess file. This prevents the private key from being viewed or downloaded.
```apache
# secure htkeyprivate file