How do I remove these white space characters from Swift Mailer? - email

My Swift Mailer code includes a variable being sent in the body. The email sends but doesn't get rid of the white space characters.
The following text: 76a7289eb67f6468356cba907809f2fd Winner :) gets translated into the following: 933eac234b1bf85619c971c4b3bf90df%20Winner%20%3A%29
This is my code:
$message = Swift_Message::newInstance('Wonderful Subject')
->setContentType("text/html")
->setBody((rawurlencode($token. " Winner :)")));
I know the email is sending. I haven't included any background information life the sender or receiver. How do I fix this problem?

Related

Why dose my mail lose some part of the content while being sent?

My code sends an email with received values.
My code:
self.alert = email.message.EmailMessage()
self.alert['Subject'] = my_subject
content1 = ''
content2 = 'ABCDEFGHIJ1ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ'
self.alert.set_content(content) #content1 or content2
self.alert['From'] = my_from
self.alert['To'] = my_to
self.smtp.send_message(self.alert)
(content1 is six consecutive 가나다라마.
In any reason, I cannot type it in the above code block.. The site rejects to post that. Maybe it's not English..?)
When I give content1, the mail of the receiver shows only some part of the content.
가나다라마가나다라마가나다라마가나다
On the other hand, for content2, even though the length is much longer than content1, it shows all the characters in the received email.
content1 contains Korean.
Does the language have to do with this problem?
When I do the same thing on my Mac, it sends Korean well.
But this problem happens when I use a remote server.
Any thought is appreciated :)
I still don't know why, but after I tried with python3.6, the issue was gone.

GMail breakpoints to hide/expand an email

Description of the issue
I am sending emails in JavaScript with
message2 = message.replace("<br>", "\n")
GmailApp.sendEmail(address, subject, message2, {
cc: cc,
name: sendername,
htmlBody: message
});
…where message is a long string containing HTML tags.
On my Gmail account the email that is received contains a … in the middle to hide/extend the end of the message. The … correspond to newlines (<br>) but it seems to chose a newline randomly that will be used to split the message randomly.
I cannot get rid of all <br> of course. I always saw these … to separate the main part of the email from the signature. But in my case it just appears anywhere as for example right after the first line:
Question
How does GMail choses the “breakpoints” for shortening the message?
How can I avoid that GMail uses “breakpoints?”
Should I use something else than <br> to make newlines?

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...

Gmail conversation grouping (threads) causing HTML email format issues

I have an HTML email that I send to my users. It looks great in all major Web, Desktop, and Mobile clients even Gmail, EXCEPT when the email is included as part of a "conversation" in Gmail. In that case, some of the table background colors don't show, the text alignment is wrong, etc. Is there a way to prevent this?
Make sure your messages have different subject lines, that'll prevent them from being in a conversation. Or, if just testing, leave the subject line blank.
Tested answer: Change the sender of your email by inserting a random number. So instead of sending from foo#bar.com, send from foo+1#bar.com. Functionally, these are the same email address (replying will send to the same person).
In ES5:
randomNumber = Math.floor(Math.random()*100).toString();
from = 'Foo <foo+' + randomNumber + '#bar.com>';
In ES6:
randomNumber = Math.floor(Math.random()*100);
from = `My Company <foo+${randomNumber}#bar.com>`;

Postfix Perl mailing via PostDrop

I'm trying to inject an email directly into the postfix queue using a perl module Mail::Postfix::Postdrop which ultilises a postfix method of allowing messages to be written directly to the postdrop directory.
There is a small amount of documentation which has enabled me to send a message successfully, however, I am confused to how I am able to set a subject and message body. An attempt to set the variable $message does little to nothing.
I must admit, I'm an apprentice to Perl at best, I would appreciate any help.
#Code which successfully sends an email:
use Mail::Postfix::Postdrop 'inject';
$message = 'test message';
inject $message, Sender => 'postmaster#mydomain.com',
Recipients => [ qw(email#someotherdomain.com) ];
Some relavant documentation:
http://annocpan.org/~PMAKHOLM/Mail-Postfix-Postdrop-0.3/lib/Mail/Postfix/Postdrop.pm
In email messages "headers" section is separated from "body" section by empty line. Just change your $message to:
$message = "Subject: This is my subject!\n\nAnd this is my message";
and you should see that you've set subject and message text. Note "\n\n", which creates empty line (double quotes are used to allow \n interpolation in $message).
Note that Mail::Postfix::Postdrop claims it accepts Email::Abstract object as a message, so you might consider using Email::Simple (or other Email::Abstract supporting class) to create your messages.