Gmail telling what I am using to send email - php

When I send an email using phpmailer to gmail, and I look the email source, I see the following next to the "from" field:
"Using PHPMailer 6.1.7 (https://github.com/PHPMailer/PHPMailer)"
For security reasons I'd prefer to remove that if it's possible, but I don't know if this is Gmail being smart or phpmailer appending it to every email message I send.
How can I remove it?
Thanks

This appears in the X-Mailer header. As per the docs, you can remove this header altogether by setting it to a space, like this:
$mail->XMailer = ' ';
If it's appearing somewhere else, I'll need to see the rest of your code and the headers of a message you've received in gmail.

Related

How to use emoji in email subject line, send via PHPMailerClass

We are trying to send email with Emoji in subject line using our Email Api which is using PHPmailer class and powerMTA port25 for relay.
surprisingly when Email sent from our Email Api reachs yahoo and when we look into "view raw message" our subject looks like:
=?utf-8?Q?=F0=9F=91=89_Overtake_The_Year_End_Price_Drop.?=
what we sent was:
👉 Overtake The Year End Price Drop
On the other hand when look into email sent from some random ESP it's "view raw message" appears as what they had sent:
Subject: 👉Updates on Your Pre-Approved Loan offer
Please help to understand where things are getting wrong.
Set PHPMailer to use UTF-8, then go ahead and use it:
$mail->CharSet = 'utf-8';
$mail->Subject = '👉 Overtake…';

Email should come under same convestaion

I am sending email using php mailer and email is going fine to the inbox
but next time when i reply back instead of email coming to under same conversation it create a new email even it should show all the email subject
any one has an idea ?
The email you send via php must have a header
Reply-To: <from-email-address>
From: <from-email-address>
as well as a
To: <destination-email-address>
header line for it to appear as a conversation thread.
Also the subject line should be the same or be the same with a prepended 'Re: '

SendGrid mail not sending (web and smtp)

I've been trying for a while to get my emails to send using SendGrid. I've set up a test PHP script:
<?php
require_once('../resources/functions/sendgrid/lib/SendGrid.php');
SendGrid::register_autoloader();
require_once('../resources/functions/unirest/lib/Unirest.php');
$sendgrid = new SendGrid('my_username', 'my_password');
$sendgrid_email = new SendGrid\Email();
$sendgrid_email->addTo('my_email#gmail.com')->
setFrom('Name <noreply#my_domain.co.uk>')->
setSubject('Name | Test Mail')->
setText("TEST MESSAGE");
$sendgrid->smtp->send($sendgrid_email);
echo 'mail sent';
?>
I've tried this using both the web and smtp methods, both methods get to the "mail sent" echo, yet neither actually appear in my inbox, and when I check my SendGrid account I still have 0 sent emails.
EDIT:
Ok, so I got it working. Removed the "name ", changed it to just "noreply#my_domain.co.uk". However, I want to define the name using the first method - any way of doing this?
ANOTHER EDIT:
Alright, Nick Q's answer fixed the rest of the issues I was having. And for anyone who is wondering, the way you set a from name (i.e Example ) is by having setFrom as just the email [setFrom("noreply#example.com")] and then using setFromName [setFromName("Example")].
Call SendGrid::register_autoloader(); after also requiring Unirest.
Otherwise your script looks good.

Processing an Email Bounce back in CakePHP and Postfix

I'm trying to handle bounced message and send to a responsible System Administrator.
I use CakePHP Email Component to send the message. On server side, I use postfix to transport the message.
function sendAsEmail($data) {
$Email->sendAs = 'html';
$Email->from = $user['Sender']['username'] . '#example.com';
$Email->return = Configure::read('App.systemAdminEmail');
$Email->bcc = array($data['Message']['recipient_text']);
$content = 'Some content';
$Email->send($content);
}
As you can see above, I set the $Email->return to sysadmin's email which it will send all the bounced message.
On postfix configuration, I tried creating a bounce.cf template and set bounce_template_file. http://www.howtoforge.com/configure-custom-postfix-bounce-messages
How do I get the bounced message and send it to System Administrator?
I think what you'll need to do is to use an SMTP (or I suppose POP3) connector for PHP. Then you'll basically have to create your own PHP email client that will login to the server, ask for the messages that have been bounced, and parse them appropriately.
I would think there would be a CakePHP component for this, but I can't find one.
I would recommend that you use an Envelope Header in your email. Otherwise you'll be stuck trying to parse the recipient server bounce, and those are very very inconsistent. If you use the VERP (variable envelope return protocol?) header, you can encode a unique hash into the email address which should be really easy to parse out in your PHPEmailClient.
More info on VERP: http://en.wikipedia.org/wiki/Variable_envelope_return_path
Cake-specific VERP stuff: http://www.mainelydesign.com/blog/view/setting-envelope-from-header-cakephp-email-component
I also highly recommend that you look into using SwiftMailer. It has a lot of plugins; you might find a base PHP SMTP client that you can easily modify to do what you need. http://swiftmailer.org/

Zend Mail sending with headers shown in body and header section in mail clients

I am using Zend Framework to send mail.
It's doing something very odd, the content type, content dispostion, MIME version and content type encoding are all showing up in the header section (under the subject) of the email in GMail and in Outlook.
The content of the email was also being included twice in the email, once as plain text and once as HTML. I stopped this by just using setBodyText() instead of using setBodyHtml() too. I had seen somewhere that you can use both. Now I just use setBodyText() like this
$mail = new Zend_Mail('utf-8');
$mail->addTo("mail#mail.com");
$mail->setSubject("Registration info");
$mail->setFrom('do-not-reply#mail.com', "A Name");
$mail->setBodyText($this->view->render('emails/register.phtml'));
$mail->send();
This has been solved. It was an error with the host receiving the email. The fact it was in Outlook or GMail made no difference as the error was with the host.

Categories