phpmailer

This commit is contained in:
2023-02-08 00:59:52 +01:00
parent 1644fede7f
commit 6a7569147e
5 changed files with 69 additions and 32 deletions

View File

@ -1,36 +1,33 @@
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: access");
header("Access-Control-Allow-Methods: POST");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
session_start();
//Load Composer's autoloader
require './classes/lib.php';
require __DIR__.'/classes/Database.php';
require __DIR__.'/classes/lib.php';
//Create an instance; passing `true` enables exceptions
$mail = new CNetcupMailer(true);
$to_email = 'p.para@gmx.de';
$subject = 'Testing PHP Mail';
$message = 'Bcc This mail is sent using the PHP mail function';
$headers[] = 'From: p.hoppe@gmx.de';
$headers[] = 'Cc: p.hoppe@gmx.de';
$headers[] = 'Bcc: dog@hope-fly.de';
try
{
$ret = mail($to_email,$subject,$message,implode("\r\n", $headers));
if($ret)
{
echo 'mail ok\n';
}
else
{
echo 'mail error\n';
}
try {
//Server settings
//Recipients
$mail->setFrom('p.para@gmx.de', 'Mailer');
$mail->addAddress('p.hoppe@gmx.de', 'Joe User'); //Add a recipient
$mail->addReplyTo('p.para@gmx.de', 'Information');
$mail->addCC('p.para@gmx.de');
$mail->addBCC('dog@hope-fly.de');
//Attachments
//Content
$mail->Subject = 'jo subject jo XXXXX';
$mail->Body = 'XXXX This is the txt message bodyThis is the txt message body This is the txt message bodyThis is the txt message body';
$mail->send();
echo 'Message has been sent';
}
catch (Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
?>