4

我有一个系统,所以人们可以通过我的 Joomla 网站注册课程(我相信它是 3.0)。但从那里,我想向人们发送一封电子邮件,填写注册中的变量。所以像:

Dear (name), thank you for registering for (class). 
This is to remind you your class is tomorrow, (date), at (place).

我相信对于注册,系统使用authorize.net

我怎样才能做到这一点?

谢谢您的帮助!!

4

2 回答 2

11

您可以使用以下帖子JFactory:getMailer中建议的方法。我在这里复制他的代码示例(修改了一下):

$subject = "Here is the subject of your message.";
$body = "Here is the body of your message.";
$user = JFactory::getUser();
$to = $user->email;
$from = array("me@mydomain.com", "Brian Edgerton");

# Invoke JMail Class
$mailer = JFactory::getMailer();

# Set sender array so that my name will show up neatly in your inbox
$mailer->setSender($from);

# Add a recipient -- this can be a single address (string) or an array of addresses
$mailer->addRecipient($to);

$mailer->setSubject($subject);
$mailer->setBody($body);

# If you would like to send as HTML, include this line; otherwise, leave it out
$mailer->isHTML();

# Send once you have set all of your options
$mailer->send();

这就是发送简单电子邮件的全部内容。如果您想添加抄送收件人,请在发送电子邮件之前包括以下内容:

# Add a blind carbon copy
$mailer->addBCC("blindcopy@yourdomain.com");

另一种选择是使用JMail::sendMailhttp ://docs.joomla.org/API17:JMail::sendMail

于 2013-09-16T04:27:43.873 回答
0

获取邮件对象:

`$mailer = JFactory::getMailer();`    

设置发件人

$user = JFactory::getUser();  
$recipient = $user->email;    
$mailer->addRecipient($recipient);    
$mailer->setSender($sender);

接受者

   $user = JFactory::getUser();    
   $recipient = $user->email;    
   $mailer->addRecipient($recipient);

创建邮件

   $body   = 'Body Text';    
   $mailer->isHtml(true);    
   $mailer->Encoding = 'base64';    
   $mailer->setBody($body);

发送邮件

$send = $mailer->Send();   
if ( $send !== true ) {    
    echo 'Error sending email: ';    
} else {    
    echo 'Mail sent';    
}

https://docs.joomla.org/Sending_email_from_extensions

于 2019-11-19T04:13:07.943 回答