我如何通过joomla发送电子邮件

时间:2013-09-16 03:44:46

标签: email joomla authorize.net

我有一个系统,所以人们可以通过我的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

我该如何做到这一点?

感谢您的帮助!!

2 个答案:

答案 0 :(得分:9)

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

$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($subject);

# 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

答案 1 :(得分: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