Skocz do zawartości

Nowy szablon forum

mygo.pl

Stworzyliśmy dla Was nowy wygląd forum. Z pewnością znajdziesz rzeczy, które wg Ciebie mogą zostać zmienione - wspomnij o tym w specjalnym wątku.

Czytaj więcej

Jak założyć własną sieć

serwerów CS

Zastanawiasz się nad prowadzeniem własnej sieci serwerów? Przeczytaj podstawowe informacje, na które należy zwrócić uwagę, przy takim projekcie.

Czytaj więcej

Tworzymy spis sieci

dodaj swoją

Dodaj sieć do której należysz, pozwoli to na promocję i budowę ogólnopolskiej bazy sieci CS.

Czytaj więcej

RSS[ANY] SMTP mail tool.


MYGO.pl
 Udostępnij

Rekomendowane odpowiedzi

  • RSSy
SMTP mail plugin(linux only)

  • Introduction:
    Since the method provided by curl.ext is not easy to use, i extracted the SMTP function from it and made it into a methodmap. Now it is easy to use plugin to send mail!.


  • Example:

    We now only use a SMTP handle to do the job and use a callback to get the result.
    PHP Code:

    Action Cmd_Status(int clientint args)
    {
        if( 
    client || client MaxClients || !IsClientInGame(client) || IsFakeClient(client) )
            return 
    Plugin_Handled;

        
    SMTP mail = new SMTP(smtp_hostsmtp_port);
        
    mail.SetVerify(smtp_encryptionsmtp_verifyhostsmtp_verifypeer);
        
    mail.SetSender(account_usernameaccount_password);
        
    mail.SetTitle("mail title");
        
    mail.AppendInfo("your mail info first line");
        
    mail.AppendInfo("your mail info second line");
        
    mail.AppendInfo("your mail info third line");

        
    mail.AddRecipient("[email protected]");
        
    mail.AddRecipient("[email protected]");

        
    mail.Send(MailSendResult);

        return 
    Plugin_Handled;
    }
    void MailSendResult(int code, const char[] message)
    {
        if( 
    code != SEND_SUCCESS )
        {
            
    LogError(message);
            return;
        }

        
    LogMessage(message);


  • Methodmap and Inc:
    PHP Code:

    /** Double-include prevention */
    #if defined _miuwiki_smtp_included_
      #endinput
    #endif
    #define _miuwiki_smtp_included_

    #define SEND_SUCCESS 67

    enum Encryption
    {
        
    Encryption_None,
        
    Encryption_STARTTLS,
        
    Encryption_SSL
    }

    /**
         * Init a curl to use smtp tools.
         *
         * @param  send_code      the curl code of the send result. check it's means in curl_header.
         * @param  message          message of this send, it is error on fail and a message on success.
         * 
         */
    typeset MailSendCallback 
    {
        function 
    void (int send_code, const char[] message);
    };

    methodmap SMTP Handle
    {
        
    /**
         * Init a curl to use smtp tools.
         *
         * @param  host                SMTP host
         * @param  port                  SMTP port
         * @param  timeout          Time to start a curl
         * @param  connect_timeout  Time to check a send mail is complete or not
         * @param  verbosity        Start curl debug or not.
         * 
         * @return                  A handle of the curl to use SMTP. or invalid_handle on fail.
         */
        
    public native SMTP(const char[] hostint portint timeout 30int connect_timeout 60int verbosity 0);

        
    /**
         * Set the smtp protocol and verify mode in the curl.
         *
         * @param  type            The SMTP server encryption type, usually use SSL
         * @param  verifyhost        The SMTP server need verify host? Most of time it is 2.
         * @param  verifypeer      The SMTP server need verify peer? if set to 1, need ca-bundle.crt.
         * 
         * @return                     True on success. false if something cause wrong.
         */
        
    public native bool SetVerify(Encryption typeint verifyhost 2int verifypeer 0);

        
    /**
         * Set the username and password of the sender.
         *
         * @param  username        SMTP username to login.
         * @param  password      SMTP password.
         * 
         * @return                     True on success. false if something cause wrong.
         */
        
    public native bool SetSender(const char[] username, const char[] password);

        
    /**
         * Set the mail titile, can hold 512 byte.
         *
         * @param  title     The title of the mail.
         * 
         * @return                  True on success. false if something cause wrong.
         */
        
    public native bool SetTitle(const char[] title);

        
    /**
         * Set the infomation of the mail, can hold 512 byte.
         *
         * @param  buffer     The infomation to send, always start on a new line.
         * 
         * @note           You must call SetTitle() before append your info in the mail!
         * 
         * @return                  True on success. false if something cause wrong.
         */
        
    public native bool AppendInfo(const char[] buffer);

        
    /**
         * Set recipients for emails, one email can have multiple recipients.
         *
         * @param  email     The email addres that recive the mail.
         * 
         * @note Please confirm the recipient before adding, and be careful not to fill in an empty string, 
         *       otherwise the email will not be sent
         * 
         * @return                  True on success. false if something cause wrong.
         */
        
    public native bool AddRecipient(const char[] email);

        
    /**
         * Send the mail through the curl handle.
         * 
         * @param callback The callback function of the send result.
         * 
         * @note The handle will auot delete when send complete even if it get wrong.
         *       Don't delete it after this function.
         * 
         * @return True if success, false otherwise.
        */
        
    public native bool Send(MailSendCallback callback);


  • Picture:

    Well it looks like a little concise..


    Attachment 202685

    Recently somebody find that split pack attack is still in L4D2 server, which make it easy to attack other server and make it lagges by some invalid pack. If someone can contact valve please tell them fix that bug as soon as possible! ( 2023.12.29 - 03 : 37 : 18 )

  • Download & Note:

    !! I don't add the AutoExecConfig() function so it will not create .cfg file. Please change it in the sp file and complie it or set it in the server.cfg.

    !! Most of the char is limit in 512 byte. If your mail lose some character maybe that you overcome the max size of buffer.


    [Download]
    Please go to Github to get the zip.

  • Thanks:

    @raydan make the curl
    @sapphonie fork the old culr and update it
    @Peace-Maker give the example to show how to send mail

Attached Thumbnails
Click image for larger version

Name:	QQ图片20231229033019.png
Views:	N/A
Size:	58.0 KB
ID:	202685  

Wyświetl pełny artykuł

Odnośnik do komentarza
Udostępnij na innych stronach

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
 Udostępnij

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...