Jump to content

Send Email by PHPMailer using SMTP


Rahat_Arif

Recommended Posts

First of all Thank you all,

My goal is to create a module that sends mail to anyone via PHPmailer using SMTP configuration.

$mail->isSMTP();                                      // Set mailer to use SMTP
        $mail->Host = 'mail.example.com';  // Specify main and backup SMTP servers
        $mail->SMTPAuth = true;                               // Enable SMTP authentication
        $mail->Username = 'user@example.com';                 // SMTP username
        $mail->Password = 'xxxxxxx';                           // SMTP password
        $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
        $mail->Port = 25;                                    // TCP port to connect to
 
        $mail->From = 'from@example.com';
        $mail->FromName = 'Mailer';
        $mail->addAddress($address);     // Add a recipient
        $mail->addReplyTo('info@example.com', 'Information');
        $mail->addCC('cc@example.com');
        $mail->addBCC('bcc@example.com');

Now for username and password, I need them to be dynamic, not manually entered. In that case, I would like to know where in the WHMCS database does this information get saved, since I have already checked the "tblconfiguration" table.

Regards

Link to comment
Share on other sites

  • 2 months later...

@berstein The "Mail Provider" settings are not reflected in the `tblconfiguration` SMTP* fields (I believe this is from version 8.0 onwards). You can verify by setting the "SMTP Host" value and then checking `SMTPHost` in the DB.  There are also many more "Mail Provider" options in UI than related fields in `tblconfiguration`. 

Does anyone know where to lookup the "Mail Provider" settings in WHMCS? I've done a complete dump of the database and grep of the file system and haven't been able to find them yet. 

Link to comment
Share on other sites

When 'MailConfig' is decrypted, the structure is like:

{
  "module": "SmtpMail",
  "configuration": {
    "encoding": "",
    "service_provider": "Generic",
    "host": "127.0.0.1",
    "port": "25",
    "auth_type": "plain",
    "username": "",
    "password": "",
    "oauth2_callback_url": "https://site/clients/admin/setup/mail/oauth2/callback",
    "oauth2_client_id": "",
    "oauth2_client_secret": "",
    "oauth2_refresh_token": "",
    "secure": "none",
    "debug": ""
  }
}

 

Link to comment
Share on other sites

@ghsa Is the "Mail Provider" you are looking the same "Mail Provider" in the "Configure Mail Provider" window?

If yes, I think the "module" is what you are looking for since the options for mail providers are equal with the mail modules inside WHMCS.
Please correct me if I'm wrong or if I misunderstand the question.

 

image.png.a2976018b5307689ca4f7ac324b85c2f.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated