[英]add e-mail recipient into php script
对于Joomla本身发送的授权邮件,无法在邮件服务器上设置CC或转发,但是我们希望存储这些电子邮件。 问题是:如何在特定插件的php中设置它? (插件正在发送这些电子邮件)代码:
// send auth email to user who signed ...
if ($signature_verification = (int)$this->settings->get('security.signature_verification', 0)) {
// unpublished, visitor must verify it first
$this->db->set('published', 0);
$config = JFactory::getConfig();
$from = $config->get('mailfrom', '');
$fromname = $config->get('fromname', '');
$recipient = (string)$this->db->get('email', '');
当我替换最后一行: $ recipient =('my@email.com')时 ,我收到了该消息,但我想给访问者一个消息并为我复制 。 谢谢你的建议
好的,实际上这段代码启动了该邮件的发送:
if (
$this->sendMail(
$from,
$fromname,
$recipient,
$subject,
$body
) !== true
) {
throw new phpmailerException(JText::_('PLG_CONTENT_CDPETITIONS_EMAIL_SEND_FAILED'), 500);
}
当我复制该代码时,将其粘贴在下面,然后用我的电子邮件替换$ recipient ,它可以起作用:我在两个地址上都传递了相同的消息。 但是我需要它具有CC(抄送)的格式,并在邮件头中具有原始收件人地址,该地址已发送给我。
对Joomla使用内置的mailer方法:
$msg = "This is my email message.";
$subject = "Database Update Email";
$to = (string)$this->db->get('email');
$config = JFactory::getConfig();
$fromemail = $config->get('mailfrom');
$fromname = $config->get('fromname');
$from = array($fromemail,$fromname);
$mailer = JFactory::getMailer();
$mailer->setSender($from);
$mailer->addRecipient($to);
$mailer->addRecipient('you1@yourdomain.com');
$mailer->addRecipient('you2@yourdomain.com');
$mailer->addCC('you3@yourdomain.com');
$mailer->addBCC('you4@yourdomain.com');
$mailer->setSubject($subject);
$mailer->setBody($msg);
$mailer->isHTML();
$mailer->send();
这应该使用PHP将HTML电子邮件发送给您想要的任何人,并根据您使用的方法通过直接发送,抄送或密件抄送在电子邮件中复制其他用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.