ලොකු help එකක් කරන්න. PHPmailer Help

tsm2016

Member
Jan 18, 2016
2
0
0
colombo
ලොකු help එකක් කරන්න. PHPmailer Help

යාලුවනේ මම එළකිරි ෆෝරම් එකට අලුත් කෙනෙක්. මම දැන් මාස 4ක් විතර ඉදන් මේකේ ත්‍රෙඩ් බලනවා. එත් මේකේ සාමාජිකයෙක් උනේ නම් නෑ. අද තමා මුලින්ම සාමාජිකයෙක් වෙලා පළවෙනියට පොස්ට් එකක් දාන්නේ. හැබැයි එකත් ප්‍රශ්නයක් කියලා කියන්න එපා. මේ දේ දන්නා අය මට උදව් කරන්න.

මම web developing වලට ටිකක් අලුත් කෙනෙක්. මට දැනගන්න ඕන php වල mail function එක වෙනුවට phpmailer script එක use කරලා mail යවන හැටි. දන්නා අය ඒ ගැන ටිකක් විස්තර කරලා එකේ parameters ටික ටිකක් විස්තර කරලා කියලා දෙන්න මට.

අපි smtp එක විදිහට gmail smtp එක use කරලා mail යවන හැටි වගේම ඊට වඩා හොද smtp තියනවා නම් ඒවත් ටිකක් කියන්න.

මේක ලොකු help එකක් යාලුවනේ මට.
 

mfdo90

Well-known member
  • Jan 6, 2009
    1,160
    168
    63
    Machan,
    Download the 5.2 stable version from here: Php Mailer

    Coding is here:


    <?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 = '[email protected]'; // 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('[email protected]', 'Mailer');
    $mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
    $mail->addAddress('[email protected]'); // Name is optional
    $mail->addReplyTo('[email protected]', 'Information');
    $mail->addCC('[email protected]');
    $mail->addBCC('[email protected]');

    // 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}";
    }


    matha meja eye thama test kale..... Localhost eke idan weda kala...
    freehosting.com eka server eke host kalata wede wune ne wage... error ekak athi hoyana gaman inne.... kiyannam
     

    windows_ubuntu

    Well-known member
  • Jun 2, 2018
    17,364
    25,879
    113
    Fantasy
    Machan,
    Download the 5.2 stable version from here: Php Mailer

    Coding is here:


    <?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 = '[email protected]'; // 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('[email protected]', 'Mailer');
    $mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
    $mail->addAddress('[email protected]'); // Name is optional
    $mail->addReplyTo('[email protected]', 'Information');
    $mail->addCC('[email protected]');
    $mail->addBCC('[email protected]');

    // 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}";
    }


    matha meja eye thama test kale..... Localhost eke idan weda kala...
    freehosting.com eka server eke host kalata wede wune ne wage... error ekak athi hoyana gaman inne.... kiyannam
    bro thread eka daapu kenaa den mail yawanna igenagena mail server ekakath aithikaarayek wendethi