我正在尝试弄清楚如何在更新时发送电子邮件。<?phpfunction my_mail_function(){ $to = "rma@mysite.net"; $subject = "RMA Update Completed"; $values2 = $row['rma_submissions.paid']; $message = " <html> <head> <title>RMA Update Complete</title> </head> <body> <p>This is a copy of your RMA Update Request</p> <table> $values2 <tr><td>Completed?: <b> Yes </b></td></tr> </table> </body> </html> "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; // More headers $headers .= 'From: <noreply@mysite.net>' . "\r\n"; mail($to,$subject,$message,$headers);}include( "lib/DataTables.php" );use DataTables\Editor, DataTables\Editor\Field, DataTables\Editor\Format, DataTables\Editor\Mjoin, DataTables\Editor\Options, DataTables\Editor\Upload, DataTables\Editor\Validate, DataTables\Editor\ValidateOptions; Editor::inst( $db, 'rma_submissions', 'ID' ) ->fields( Field::inst( 'rma_submissions.id' ), Field::inst( 'rma_submissions.timestamp' ) ->validator( Validate::dateFormat( 'Y-m-d H:i:s' ) ) ->getFormatter( Format::datetime( 'Y-m-d H:i:s', 'Y-m-d H:i:s' ) ) ->setFormatter( Format::datetime( 'Y-m-d H:i:s', 'Y-m-d H:i:s' ) ), Field::inst( 'rma_submissions.location' ), Field::inst( 'rma_submissions.orig_invoice' ), Field::inst( 'rma_submissions.all_accessories' ), Field::inst( 'rma_submissions.new_submission' ), Field::inst( 'rma_submissions.man_sku' ), Field::inst( 'rma_submissions.device_id' ), Field::inst( 'rma_submissions.failure_desc' ), Field::inst( 'rma_submissions.defective_oob' ), Field::inst( 'rma_submissions.original_sales_date' ),上面的方法不能正常工作。它发送电子邮件,但在前端出错,并且也不包含变量信息。如果我只添加文本,它发送得很好,但是当我添加任何变量时,它会出错。这一定是我提取变量的方式上的错误。
1 回答
拉丁的传说
TA贡献1789条经验 获得超8个赞
来自 PHP 文档https://www.php.net/manual/en/language.types.string.php#language.types.string.parsing
查看给出的示例,数组的变量扩展不应包含引号。请尝试:
查看给出的示例,数组的变量扩展不应包含引号。请尝试:
$message = "
<html>
<head>
<title>Sku Update Complete</title>
</head>
<body>
$row[rma_submissions.paid]
</body>
</html>
";
一般来说,由于变量扩展的复杂性,我倾向于使用串联。IE
$message = "
<html>
<head>
<title>Sku Update Complete</title>
</head>
<body>".$row['rma_submissions.paid']."</body>
</html>
";
或者我会创建一个简单的模板,然后使用 preg Replace 等将字段占位符替换为实际值。
- 1 回答
- 0 关注
- 94 浏览
添加回答
举报
0/150
提交
取消