Files
claudetools/clients/dataforth/scripts/Test-DataforthSMTP.ps1
Mike Swanson 5cbd49ce24 Reorganize repo: compartmentalize scripts by client/project
Move 150+ scripts from root and scripts/ into client/project directories:
- clients/dataforth/scripts/ (110 files: AD2, sync, SSH, DB, DOS scripts)
- clients/bg-builders/scripts/ (14 files: Lesley mgmt, Exchange, termination)
- clients/internal-infrastructure/scripts/ (10 files: GDAP, Gitea, backups)
- projects/msp-tools/scripts/ (9 files: CIPP, MSP onboarding, Datto)
- projects/gururmm-agent/scripts/ (3 files: API test, JWT, record counts)
- clients/glaztech/scripts/ (1 file: CentraStage removal)

Also reorganized:
- VPN scripts → infrastructure/vpn-configs/
- Retrieved API/JS files → api/
- Forum posts → projects/community-forum/forum-posts/
- SSH docs → clients/internal-infrastructure/docs/
- NWTOC/CTONW docs → projects/wrightstown-smarthome/docs/
- ACG website files → projects/internal/acg-website-2025/
- Dataforth docs → clients/dataforth/docs/
- schema-retrieved.sql → docs/database/

Deleted 24 tmp_*.ps1 one-off debug scripts (preserved in git history).
Root reduced from 220+ files to 62 items (docs + directories only).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 17:15:07 -07:00

70 lines
3.2 KiB
PowerShell

# Test SMTP Authentication for notifications@dataforth.com
# This script tests SMTP authentication to verify credentials work
param(
[string]$Password = $(Read-Host -Prompt "Enter password for notifications@dataforth.com" -AsSecureString | ConvertFrom-SecureString)
)
$SMTPServer = "smtp.office365.com"
$SMTPPort = 587
$Username = "notifications@dataforth.com"
Write-Host "[OK] Testing SMTP authentication..." -ForegroundColor Green
Write-Host " Server: $SMTPServer"
Write-Host " Port: $SMTPPort"
Write-Host " Username: $Username"
Write-Host ""
try {
# Create secure password
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential($Username, $SecurePassword)
# Create SMTP client
$SMTPClient = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = $Credential
# Create test message
$MailMessage = New-Object System.Net.Mail.MailMessage
$MailMessage.From = $Username
$MailMessage.To.Add($Username)
$MailMessage.Subject = "SMTP Test - $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
$MailMessage.Body = "This is a test message to verify SMTP authentication."
Write-Host "[OK] Sending test email..." -ForegroundColor Green
$SMTPClient.Send($MailMessage)
Write-Host "[SUCCESS] SMTP authentication successful!" -ForegroundColor Green
Write-Host " Test email sent successfully." -ForegroundColor Green
Write-Host ""
Write-Host "[OK] The credentials work correctly." -ForegroundColor Green
Write-Host " If the website is still failing, check:" -ForegroundColor Yellow
Write-Host " - Website SMTP configuration" -ForegroundColor Yellow
Write-Host " - Firewall rules blocking port 587" -ForegroundColor Yellow
Write-Host " - IP address restrictions in M365" -ForegroundColor Yellow
} catch {
Write-Host "[ERROR] SMTP authentication failed!" -ForegroundColor Red
Write-Host " Error: $($_.Exception.Message)" -ForegroundColor Red
Write-Host ""
if ($_.Exception.Message -like "*authentication*") {
Write-Host "[ISSUE] Authentication credentials are incorrect" -ForegroundColor Yellow
Write-Host " - Verify the password is correct" -ForegroundColor Yellow
Write-Host " - Check if MFA requires an app password" -ForegroundColor Yellow
} elseif ($_.Exception.Message -like "*5.7.57*") {
Write-Host "[ISSUE] SMTP AUTH is disabled for this tenant or user" -ForegroundColor Yellow
Write-Host " Run: Set-CASMailbox -Identity notifications@dataforth.com -SmtpClientAuthenticationDisabled `$false" -ForegroundColor Yellow
} elseif ($_.Exception.Message -like "*connection*") {
Write-Host "[ISSUE] Connection problem" -ForegroundColor Yellow
Write-Host " - Check firewall rules" -ForegroundColor Yellow
Write-Host " - Verify port 587 is accessible" -ForegroundColor Yellow
}
}
Write-Host ""
Write-Host "================================================================"
Write-Host "Next: Check Exchange Online logs for more details"
Write-Host "================================================================"