• 08-05-2020, 13:43:17
    #1
    Merhaba bir adet html tasarımım var. İletişim formundan mail göndermek istiyorum ama sanırım ayarları yapamadım. Aşağıdaki gibi dosyalarım var. Yardımcı olabilir misiniz ?

    Config.json dosyamdaki kod


    Contact-Form.php dosyam

  • 08-05-2020, 13:53:54
    #2
    hostun mail cikisina izin veriyor mu?
    muhtemelen kapalidir.
  • 08-05-2020, 13:55:22
    #3
    Smtp ile neden göndermiyorsun?
  • 08-05-2020, 13:57:18
    #4
    ataliemre adlı üyeden alıntı: mesajı görüntüle
    Smtp ile neden göndermiyorsun?
    Maalesef html de smtp olayını bilmiyorum. WordPress de evet kullanıyorum ama html de ilk defa yapıyorum



    kavas adlı üyeden alıntı: mesajı görüntüle
    hostun mail cikisina izin veriyor mu?
    muhtemelen kapalidir.
    Mail gönderebiliyorum ve alabiliyorum.
  • 08-05-2020, 14:18:39
    #5
    Merhaba,

    Bu fonksiyon phpmail fonksiyonudur ve %99.9 sunucuda kapalıdır.
    Sunucu sizin dahi olsa kapatmanız önerilir.
    Bu durumda tek çareniz SMTP mail fonksiyonunu kullanmak.
    https://github.com/PHPMailer/PHPMailer

    Bu kaynaktan yararlanarak SMTP üzerinden gönderim yapabilirsiniz.

    Örnek:

    <?php
    // Import PHPMailer classes into the global namespace
    // These must be at the top of your script, not inside a function
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\SMTP;
    use PHPMailer\PHPMailer\Exception;
    
    // Load Composer's autoloader
    require 'vendor/autoload.php';
    
    // Instantiation and passing `true` enables exceptions
    $mail = new PHPMailer(true);
    
    try {
    //Server settings
    $mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output
    $mail->isSMTP(); // Send using SMTP
    $mail->Host = 'smtp1.example.com'; // Set the SMTP server to send through
    $mail->SMTPAuth = true; // Enable SMTP authentication
    $mail->Username = 'user@example.com'; // SMTP username
    $mail->Password = 'secret'; // SMTP password
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
    $mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
    
    //Recipients
    $mail->setFrom('from@example.com', 'Mailer');
    $mail->addAddress('joe@example.net', 'Joe User'); // 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');
    
    // Attachments
    $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
    $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
    
    // Content
    $mail->isHTML(true); // Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    
    $mail->send();
    echo 'Message has been sent';
    } catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
  • 08-05-2020, 14:22:36
    #6
    Scorpion2763 adlı üyeden alıntı: mesajı görüntüle
    Merhaba,

    Bu fonksiyon phpmail fonksiyonudur ve %99.9 sunucuda kapalıdır.
    Sunucu sizin dahi olsa kapatmanız önerilir.
    Bu durumda tek çareniz SMTP mail fonksiyonunu kullanmak.
    https://github.com/PHPMailer/PHPMailer

    Bu kaynaktan yararlanarak SMTP üzerinden gönderim yapabilirsiniz.

    Örnek:

    <?php
    // Import PHPMailer classes into the global namespace
    // These must be at the top of your script, not inside a function
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\SMTP;
    use PHPMailer\PHPMailer\Exception;
    
    // Load Composer's autoloader
    require 'vendor/autoload.php';
    
    // Instantiation and passing `true` enables exceptions
    $mail = new PHPMailer(true);
    
    try {
    //Server settings
    $mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output
    $mail->isSMTP(); // Send using SMTP
    $mail->Host = 'smtp1.example.com'; // Set the SMTP server to send through
    $mail->SMTPAuth = true; // Enable SMTP authentication
    $mail->Username = 'user@example.com'; // SMTP username
    $mail->Password = 'secret'; // SMTP password
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
    $mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
    
    //Recipients
    $mail->setFrom('from@example.com', 'Mailer');
    $mail->addAddress('joe@example.net', 'Joe User'); // 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');
    
    // Attachments
    $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
    $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
    
    // Content
    $mail->isHTML(true); // Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    
    $mail->send();
    echo 'Message has been sent';
    } catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
    Örnek attığınız kodu mail.php dosyasına eklesem ve dosyayı sunucuya yüklesem mail gönderebilirim bilgileri doldurduktan sonra doğru mudur ? Ayrıca teşekkür ederim.
  • 08-05-2020, 14:24:19
    #7
    Misafir adlı üyeden alıntı: mesajı görüntüle
    Örnek attığınız kodu mail.php dosyasına eklesem ve dosyayı sunucuya yüklesem mail gönderebilirim bilgileri doldurduktan sonra doğru mudur ? Ayrıca teşekkür ederim.
    Evet doğrudur, ancak bunun için de SMTP üzerinden çıkış iznini olması gerekiyor. Bu büyük ihtimalle hostinginizde açıktır, gönderimi sağlayamazsanız yer sağlayıcınız ile görüşün.

    Rica ederim.