load magento email template - email

I'm using my own code to send out SMS's to the customers at the same time as the emails go out. I do this by getting the email template code with
$code = $this->getTemplateCode();
and then trying to load the corresponding SMS template with
$sms = $this->loadByCode('sms_'.$code)->getTemplateText();
I then check if $sms is empty before proceeding to send the text, meaning that I can add or remove connected SMS templates at will. The problem I'm having is that I sometimes, when there is no connected "sms_*" template, I get the full email sent out as the SMS instead of no text being sent.
I've debugged the code by sending out the template it tries to load as the actual SMS, and received "sms_creditmemo", but when I instead load it with the method above and do a var_dump($sms); exit;it shows me that it loaded the template "creditmemo_invoice" which is the email template I use instead of "creditmemo" when the payment method is detected. I make sure to use the original template string in $code (used to load SMS template) no matter the payment method.
Now my question would be how this can even be possible, does the loadByCode take best matching template or is there some other more serious bug I've missed, maybe there's better ways to load in the templates and make correct checks to see if they even exist?

I solved this by checking if the correct email template gets loaded with
if ($this->loadByCode($template)->getTemplateCode() == $template)

Related

Magento print transcational emali before mail send

is it possible to print transaction email body before email send? I just want to see how to display layout after display value in transactional email.
All Magento emails are send through this method: Mage_Core_Model_Email_Template::send().
Here is how I usually check my e-mail templates. In the method mentioned above, right after these lines:
if($this->isPlain()) {
$mail->setBodyText($text);
} else {
$mail->setBodyHTML($text);
}
I add this:
echo $text;exit;
instead of sending an e-mail it just prints it in the browser.
Don't forget to remove this line after you're done testing.
If you want to use the this in a live environment and save all the send e-mails you will have to do a more elaborate thing, live overriding the class, and not stopping the script at all, but you can do all this in the same place.

Processing tokens through Drupal Rules

I am using the Rules module to respond to specific events and send email alerts. This part of my project works fine.
My problem is I need to include some dynamic data in the email message. For this I am using Tokens but the tokens do not get processed and replaced with the neccessary text. This means the email gets delivered with tokens in the message.
Can anyone suggest how I can solve this problem either programmatically or via some configuration I am missing?
I'm using Rules for emails also and hav not encountered any issues using tokens
This is an example of the body of the email from one of my rules
New Issue --> [node:url]
Title - [node:title]
Description - [node:body]
Author - [node:author]
Priority - [node:field-issue-priority]
Category - [node:field-issue-category]
Maybe you do not have the proper format?

Expression Engine using the Champagne Extension troubleshooting

I have an issue in Expression Engine using the Champagne Extension where it won't allow me to send out campaigns. This extension utilizes https://www.campaignmonitor.com/ api to send out mass emails.
The Error I get is "HTML Content URL Required" when I try to send out campaigns form the back end of the Expression Engine Install.
What could be causing this issue that relates to the expression engine install?
This error is received anytime the URL to your html or text content is not visible. More often this is seen when someone forget to include the text version. A good way to test is to click the preview HTML/TEXT button and make sure both give you the correct results.
They cannot be blank.
For an alternative solution, be sure to checkout my add-on Postmaster. It allows clients to publish email campaigns just by creating a new entry. You can setup any number of configuration, so you can even send draft email to a test subscriber list. And since everything is within channel entries, you can use whatever fieldtypes you like, and it works with MailChimp as well as CampaignMonitor.
https://objectivehtml.com/articles/postmaster-the-definitive-email-solution-for-expressionengine

Force.com email service

I have created an email service in force.com.Can anyone help me out of how to use thta in apex classes.say,i wanna send mail when user registration is successful??
Many Thanks,
Sandhya Krishnan
I assume you want to send an email directly from Apex code, either in a Trigger or from a page controller ... ? If so, this page can get you started:
http://www.forcetree.com/2009/07/sending-email-from-your-apex-class.html
Clearly you don't want to hard-code your email template into your classes, so make sure to read at least through the part that shows how to look up the template dynamically. That should be enough to get you on your way.

File uploading and email in JSP

I need to make a simple page in JSP. I've never worked in JSP before ever.
I have a form that has two fields: one is a file upload field and the other is a textbox. The user enters one email address in the field and uploads a file and upon submission. I should be able to email the attachment to the email address entered.
I need a quick code snippet that does this.
try to see this code, might need some debugging though :)
or this one from here (through the JavaMail API):
SmtpSender smtp=SmtpSender.getInstance();
MailToBeSent send=new MailToBeSent();
send.setSubject("Hello");
send.setFromAddress("some#bar.com","Someone");
send.addToAddress("another#foo.com","Anotherone");
send.setBody("Hello, test with the file attachment!");
byte[] bin=.....
send.attacheFile(bin,"photo.jpg","image/jpeg");
smtp.sendMail(send);