"Illegal address in String" email template in CQ5 javax.mail - aem

Working on a customised email template in CQ5, I have created in following text file under etc/notification. The workflow is triggered when a form is filled in by the user.
From: Order Brochure <order.brochures#gmail.com>
To: ${payload.email}
CC:
Subject: Order Brochures Confirmation ${payload.BrochureID}
Dear ${payload.Name},
Thank you for your Brochure Order, your reference is ${payload.orderBrochureID}.
Your email address is {$payload.email}.
Everything in this template works fine, except for the "To: ${payload.email}". Even the "Your email address is {$payload.email}" part displays the user inputted email fine. It also works if I input a static email address in "To:".
What am I doing wrong here? Below is the error in logs
Process execution resulted in an error:
javax.mail.internet.AddressException: Illegal address in string ``''
com.day.cq.workflow.WorkflowException: javax.mail.internet.AddressException: Illegal
address in string ``''

Remove the "CC:" it's attempting to parse the email address for this header and it's a null.
When you're dealing with these types of problems when the error is occurring within a CQ library. I recommend using a custom logger to assist with the troubleshooting.
Details of logging can be found at Logging - docs.day.com
Here's an example OSGi log configuration for your issue.

This error might be cumming because you are using a string as an Internet Address.
you need to typecast ${payload.email} to Internet Address.

Related

Mail Session settings at Websphere Server

The mails are sent with default From address as wasadm#servername which I want to change. I tried using the property mailFrom at application.inf file, changed the values at websphere console - Resources >> Mail >> Mail Sessions >> Return e-mail address but nothing worked out.
Could you please let me know if you have some solution to replace the default from mail address to a custom value.
Normally, the email-sending application code sets a "from" address in the message itself.
That said, I think it might work to set a Mail Session Custom property of mail.from. According to https://javaee.github.io/javamail/docs/api/overview-summary.html:
mail.from The return email address of the current user, used
by the InternetAddress method getLocalAddress.
I know from experience that the envelope sender address can be set with Custom property mail.smtp.from. See https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html
mail.smtp.from Email address to use for SMTP MAIL command. This sets the envelope
return address. Defaults to msg.getFrom() or
InternetAddress.getLocalAddress(). NOTE: mail.smtp.user was previously
used for this.

Email Error: missing or malformed local part

I am noticing that I get an email from my server each time an order is placed. It looks like the customer confirmation emails are not sending.
This is part of the error message:
A message that you sent contained one or more recipient addresses that were
incorrectly constructed:
=?utf-8?B?R3Vlc3Q=?= <>: missing or malformed local part
This address has been ignored. The other addresses in the message were
syntactically valid and have been passed on for an attempt at delivery.
------ This is a copy of your message, including all the headers. ------
To: =?utf-8?B?R3Vlc3Q=?= <>
Subject: =?utf-8?B?SW50ZWxsaWdlbnQgV29ya3Nob3A6IE5ldyBPcmRlciAjIDEwMDAwMDAzMA==?=
It looks like it’s only when the user checks out without registering
=?utf-8?B?R3Vlc3Q=?= <>: missing or malformed local part
The error message is quite obvious: There should be an email address between <>, but there is none. The local part is the part of the address before the #, and as there is nothing at all here, there is no local part. Thus your server is complaining.
You have to fix whatever application is trying to send mails to <> to get rid of the error.
The email address is not written in proper format, please use <>
I really don't Understand what you are trying to do. But This is what I found out playing around with this error.
$to = "'Name of Person' <email#example.com>";
$headers = "From: ".$_POST['theirName']."<".$_POST['theirEmail'].">\r\n";
$subject = $_POST['subject'];
$messageBody = $_POST['message']."\r\n ---\n This Message was sent from ".HOME." contact form.";
mail($to,$subject,$messageBody,$headers);
Notice that around the 'Name of Person' has single quotes. If you are trying to send emails with an additional name, title or anything else in front of the emails. With the single quotes will let PHP know that it is not an email but a string, and it will add the string but be ignored as an email, not giving you the error anymore.
The header where it states from does not need to have the single quotes.
=?utf-8?B?R3Vlc3Q=?= <-This line I don't know what it supposed to be doing.
But it's not an Email on the $to/$recipient and for that reason it giving the error. Once again, must have only emails: "email1#example.com, email2#example.com" other than that: 'String' with single quotes no error will produce...

Magento invalid email address

I'm trying to add my email address in Store Email Address, But it is saying "Invalid email address "admin#mydomain"."
Note that my tld is uncommon.
I think that is the reason for the error message.
I can add .com email address easily btw.
Is there any way to add the email?
Thank you.
in validation.js you have
['validate-email', 'Please enter a valid email address. For example johndoe#domain.com.', function (v) {
return Validation.get('IsEmpty').test(v) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*#([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(v)
}],
You will have to play with this regular expression.
if you look into this expression you will find a . jsut remove every thing excluding ] from . till end and should solve.
I had the same issue, but your suggestions were misleading.
The error message comes up not from this java script, but app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Email/Address.php
The error is generated from lib/Zend/Validate/EmailAddress.php, because it calls hostname verification from Hostname.php in the same directory.
There you can find in row nr. 117 an array called $_validTlds
there put your domain ('works' or in my case 'wien'), take care alphabetical order, and quotes and commas. save and try again,
it will work. Good luck.

Magento - How to format the email address in "Store Email Addresses"?

What I'm trying to do is format the email address like so Foo Bar <foo#bar.com> so email clients (including web based like gmail) will show the sender as "Foo Bar" and not just "foo" since that is the prefix on the email.
Is this possible in Magento 1.5? If I try to put the formatting in the field itself I get an error message.
That's what the Sender Name field does. This is what my setup looks like and what it looks like in Thunderbird (my webmail client formats it similarly, too):
You may look at code/core/Mage/Core/Model/Email.php for the actual mail implementation. You may notice it uses Zend_Mail. Now, here is the catch:
For security reasons, Zend_Mail filters all header fields to prevent header
injection with newline (\n) characters. Double quotation is changed to single
quotation and angle brackets to square brackets in the name of sender and recipients.
If the marks are in email address, the marks will be removed.
What you can do though is to make a module to rewrite the current class Mage_Core_Model_Email and overwrite the send() function. I covered rewriting classes before in this question's answer. Then, in this new rewritten class, you could PHPmailer, invoke shell mail commands, or whatever PHP library you would happen to know that would allow this behaviour.
Best of luck.
I'm not sure if it can work. In magento inside is a Zend_Validate which does validation of such email addresses. And I dont think so that email like 'Foo Bar ' is valid. But I think the display in customer's email client depend on client, no?

Hudson email ext plugin bug?

I am getting an error using my email ext plugin from hudson.
I am trying send an email to the following schema:
"< firstName >_< LastName >#< subgroup >.< companyName >.com
ex: John_Doe#stacks.stackoverflow.com
I cannot send emails to this address via the email extension plugin.
The regular email generator works with this address schema.
I am wondering if the Address Checker module in the plugin is too strict about the address name.
Is there any workaround?
I get the following spew from Hudson:
Jun 22, 2009 2:48:53 PM hudson.plugins.emailext.ExtendedEmailPublisher sendMail
WARNING: Could not send email.
javax.mail.internet.AddressException: Illegal address in string ``''
at javax.mail.internet.InternetAddress.(InternetAddress.java:94)
at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:287)
at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:249)
at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:241)
at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:199)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:372)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:360)
at hudson.model.Build$RunnerImpl.cleanUp(Build.java:188)
at hudson.model.Run.run(Run.java:962)
at hudson.model.Build.run(Build.java:112)
at hudson.model.ResourceController.execute(ResourceController.java:93)
at hudson.model.Executor.run(Executor.java:119)
Is this really how you have it in Hudson?
"< firstName >_< LastName >#< subgroup >.< companyName >.com
(you have an open quote but no close quote)
If so, that may be your problem.
Yup this is a bug (HUDSON-7057).
Based off of the latest code in the trunk:
this fails: " email1#server.com email2#server.com"
works as expected: "email1#gmail.com email2#gmail.com "
works as expected: "email1#gmail.com email2#gmail.com"
Scrutinize what you put in the recipient list for random whitespace.
I'm using that plugin too and I haven't had any such problems.
The warning appears to be complaining about your configuration. Maybe you'd want to double-check the email address that you typed? Whitespace as separator char for multiple emails? Also, double-check your sytem configuration and make sure you've configured your SMTP server or the default suffix correctly.
You can browse the code but I would guess that the javax mail validator is not too strict - it's built in to java. In the latest code, I don't see the InternetAddress(String) constructor on line 287, so I wonder what version of the plugin you are currently using.
Also, what options do you have selected for email? Send to culprits?