program development

Dream weaving dedecms custom form sends to the specified mailbox

How to send a custom form to a designated mailbox? Many people use the Dream Weaving Dedecms custom form to make online orders, online registrations,[…]

article directories

How to send a custom form to a designated mailbox? When many people use the Dream Weaving Dedecms custom form to make online orders, online registrations, online messages, and feedback, they want users to send the form to their mailbox when submitting it. This eliminates the need to log in to the background of the website every day to check the message status.

So how to submit the form to the specified mailbox using a dream weaving custom form?

1. First of all, in the background of the Dream Weaving website, enter the system-basic system parameters-core settings, as shown below:

Step 2: Open the diy.php file below plus:

Line 85:$query ="INSERT INTO `{$diy->table}` (`id`, `ifcheck` $addvar) VALUES (NULL, 0 $advalue);";

Start adding code later:

$mailtitle = $name.”Submit Form Notification ";

$mailbody ="Address: {$name}\r\nEmail: {$email}\r\nContent: {$message}";

$headers = $cfg_adminemail;

$mailtype = ‘TXT’;

require_once(DEDEINC.’/ mail.class.php’);

$smtp = new smtp($cfg_smtp_server,$cfg_smtp_port,true,$cfg_smtp_usermail,$cfg_smtp_password);

$smtp->debug = false;

$smtp->sendmail($cfg_smtp_usermail,$cfg_webname ,$cfg_smtp_usermail, $mailtitle, $mailbody, $mailtype);

Note: The three variables $name $email $message are all submitted fields. You just need to add a $sign in front of the field name you submit. This can be changed according to your needs. Then save.

Pay special attention. If the website uses a foreign server, you need to handle the second step.

Generally, websites use domestic servers and the code given in step 2, so that the administrator can send letters to themselves through the mailbox, and the content can be obtained through the id number. However, American hosts restrict themselves from sending emails to themselves, so in step 2, the last sentence of the code must be changed to:

$smtp->sendmail($cfg_smtp_usermail,$cfg_webname ,$cfg_smtp_usermail, $mailtitle, $mailbody, $mailtype);

//Send email, sendmail(recipient, website name, sender, message title, message content, message type), redefine the recipient,

For example:

$cfg_smtp_usermail2="Write the mailbox you specified here";

$smtp->sendmail($cfg_smtp_usermail2,$cfg_webname ,$cfg_smtp_usermail, $mailtitle, $mailbody, $mailtype);

So you can receive it. It is indeed feasible after testing by bloggers.