Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From property doesn't work #55

Closed
valx76 opened this issue May 1, 2013 · 11 comments
Closed

From property doesn't work #55

valx76 opened this issue May 1, 2013 · 11 comments

Comments

@valx76
Copy link

valx76 commented May 1, 2013

Hi,

I have a problem with the "From" property in PHPMailer.
I'm using GMail (as SMTP and sender) and when I receive a mail sent by PHPMailer, it has the good "FromName" property but not the "From" one (it shows the SMTP address instead).

That's my code :

// SMTP Settings
$phpmailer->From = $settings['from_email'];
$phpmailer->FromName = $settings['from_name'];

Thanks !

@Synchro
Copy link
Member

Synchro commented May 1, 2013

Can you provide some more info? De-personalised headers would be good.

@valx76
Copy link
Author

valx76 commented May 1, 2013

What info do you need @Synchro ?

@Synchro
Copy link
Member

Synchro commented May 1, 2013

Like I said - the received headers you're seeing, the values you're putting into your config. I don't know what you mean by 'SMTP address'.

@valx76
Copy link
Author

valx76 commented May 1, 2013

Oh right. By SMTP adress, I mean SMTP host (GMail here).

Code - SMTP config :

$phpmailer->IsSMTP();
$phpmailer->Host = 'smtp.gmail.com';
$phpmailer->SMTPAuth = true;
$phpmailer->Username = 'alctest76@gmail.com';
$phpmailer->Password = '__';
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->Port = 465;

In the header, I have : "From: Val alctest76@gmail.com".
"Val" is the name I pass to the "FromName" property so it works.
But as you can see, the "From" property is not applied, the adress is one use for SMTP authentication..

@sabl0r
Copy link

sabl0r commented May 1, 2013

I think gmail doesn't let you set From to an address, which isn't confirmed in your gmail account.

@Synchro
Copy link
Member

Synchro commented May 1, 2013

Can you view source on the message and paste the exact headers? What would be useful is to get the headers generated before sending (look at $phpmailer->PreSend()) too so we can see if gmail is altering them.

What @sabl0r is probably true too.

Incidentally you're using obsolete settings for gmail - you should be using:

$phpmailer->SMTPSecure = 'tls';
$phpmailer->Port = 587;

@valx76
Copy link
Author

valx76 commented May 1, 2013

I modified the SMTP for GMail, thanks for that !
The $phpmailer->PreSend() function just returns me true..

And finally, here is the headers :

Delivered-To: valx76@gmail.com
Received: by 10.204.228.197 with SMTP id jf5csp21717bkb;
        Wed, 1 May 2013 10:34:56 -0700 (PDT)
X-Received: by 10.180.182.110 with SMTP id ed14mr30792578wic.6.1367429696334;
        Wed, 01 May 2013 10:34:56 -0700 (PDT)
Return-Path: <alctest76@gmail.com>
Received: from mail-wi0-x242.google.com (mail-wi0-x242.google.com [2a00:1450:400c:c05::242])
        by mx.google.com with ESMTPS id mb1si172485wic.91.2013.05.01.10.34.56
        for <valx76@gmail.com>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 01 May 2013 10:34:56 -0700 (PDT)
Received-SPF: pass (google.com: domain of alctest76@gmail.com designates 2a00:1450:400c:c05::242 as permitted sender) client-ip=2a00:1450:400c:c05::242;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of alctest76@gmail.com designates 2a00:1450:400c:c05::242 as permitted sender) smtp.mail=alctest76@gmail.com;
       dkim=pass header.i=@gmail.com
Received: by mail-wi0-x242.google.com with SMTP id hi8so769860wib.9
        for <valx76@gmail.com>; Wed, 01 May 2013 10:34:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-received:date:to:from:subject:message-id:x-priority:x-mailer
         :mime-version:content-transfer-encoding:content-type;
        bh=sRlGTsD70quVJL3NKaMh1HXmdtMDcDlI5yPTBH/emo8=;
        b=dqOTTcxL1aC51lsJEb8NDVrf3JXnaWdUL2OpXbCM2hsK/Vz3Wiw/zpEaa6ukIbrWF8
         FtYSC37vl/vvOWR3f28Kq791u49uGfb0+l2VZfQIfpTX/W3knNEvyVgRq5N9ZWWAtFz0
         LVX1Dg1IZ0eBP4Cs8hfxX0yXjdBsWrPSUaddTrGkpsZACG4x7Ffy2HLGTPEoZ1VorDjB
         3ZyQHBw1S4Z+09/WzeHZDuVDxsbPtKdUA+HmvoJ9Y3iEwLThBY+pCzxlU//5ErVPzJW4
         w8iKuTAsVtbxAFtY8PV381lRE3cUGb7Ryt3fiIKZ1VE1mRBvp125vuh4Gm2qNc+3Z+Vj
         oYQw==
X-Received: by 10.180.105.231 with SMTP id gp7mr3461230wib.23.1367429696247;
        Wed, 01 May 2013 10:34:56 -0700 (PDT)
Return-Path: <alctest76@gmail.com>
Received: from 127.0.0.1   [[JUST REMOVED MY IP HERE]]
        by mx.google.com with ESMTPSA id x13sm5338346wib.3.2013.05.01.10.34.53
        for <valx76@gmail.com>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 01 May 2013 10:34:55 -0700 (PDT)
Date: Wed, 1 May 2013 17:34:51 +0000
Return-Path: <valx76@gmail.com>
To: valx76@gmail.com
From: Wordpress testing <alctest76@gmail.com>
Subject: Newsletter to contributors
Message-ID: <836c2d45732bdec667412612d2a352d5@127.0.0.1>
X-Priority: 3
X-Mailer: PHPMailer 5.2.6 (https://github.com/PHPMailer/PHPMailer/)
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset=iso-8859-1

@Synchro
Copy link
Member

Synchro commented May 1, 2013

That's good - we can see that the 'From' header is missing an address. Now for checking what was sent:

$phpmailer->PreSend();
echo $phpmailer->MIMEHeader;

and compare the two (ignoring 'received' headers). If the From header was set correctly before sending, it does indeed look like gmail is stripping it.

@valx76
Copy link
Author

valx76 commented May 2, 2013

I tried to put your code before the email sending but it gives me an error :
Fatal error: Cannot access protected property PHPMailer::$MIMEHeader

@Synchro
Copy link
Member

Synchro commented May 2, 2013

Either subclass it or call GetSentMIMEMessage() instead.

@valx76
Copy link
Author

valx76 commented May 2, 2013

What I have with GetSentMIMEMessage() is :

Date: Thu, 2 May 2013 17:55:44 +0000
Return-Path: 
To: valx76@gmail.com
From: Wordpress testing 
Subject: Newsletter to contributors
Message-ID: <1714bd4c92518b8e7644c30334bfbae2@127.0.0.1>
X-Priority: 3
X-Mailer: PHPMailer 5.2.6 (https://github.com/PHPMailer/PHPMailer/)
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="b1_1714bd4c92518b8e7644c30334bfbae2"

So, Gmail seems to break the From (email) attribute.

Thanks for the help, I'm closing the issue !

@valx76 valx76 closed this as completed May 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants