Posts mit dem Label Mail werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Mail werden angezeigt. Alle Posts anzeigen

18.05.15

Email per Powershell versenden

Hier eine kurze Anleitung, wie man in Windows mittels Powershell Emails versenden kann.

Ausführen von Skripten prüfen und gegebenenfalls erlauben: 


C:\> Get-ExecutionPolicy -List
C:\> Set-ExecutionPolicy RemoteSigned


Skript zum versenden von Mails erstellen:

$EmailFrom = "sender@domain.com"
$EmailTo = "recipient@otherdomain.com"
$Subject = "Betreff"
$Body = "Was soll in der Mail stehen?"
$SMTPServer = "smtp.domain.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("usr", "pass");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)


$EmailFrom, $EmailTo, $SMTPServer, "usr" und "pass" müssen durch die entsprechenden Werte ersetzt werden.

26.09.14

[CentOS 6] Office 365 als SMTP relay für Postfix nutzen

Benötigte Pakete installieren:
yum install postfix cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain

Relayhost konfigurieren:
postconf -e 'relayhost = smtp.office365.com:587'

TLS Verschlüsselung aktivieren:
postconf -e 'smtp_tls_security_level=encrypt'

IPv6 als Internet Protokoll deaktivieren:
postconf -e 'inet_protocols=ipv4'


Authentifizierung aktivieren, auth mapping Datei erstellen und in auth Datenbank konvertieren:
postconf -e 'smtp_sasl_auth_enable = yes'
postconf -e 'smtp_sasl_security_options = noanonymous' 
postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd'
echo "smtp.office365.com user@domain.com:password" > /etc/postfix/sasl_passwd
chown root:root /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd

Namenszuordnung erstellen um zu erreichen, dass Exchange Mails annimmt:
postconf -e 'canonical_maps = hash:/etc/postfix/canonical'
vi /etc/postfix/canonical
root    nagios@netbiscuits.com
postmap /etc/postfix/canonical