You are not logged in.
Pages: 1
Hello,
I set up msmtp, and the php mail function sends messages successfully, but the FROM address is missing.
I followed the howto at http://forum.slicehost.com/comments.php … ionID=2338.
Here's my sysconfig /etc/msmtprc:
account default
host smtp.mydomain.com
port 25
timeout 30
auth on
user user@mydomain.com
password secret
auto_from off
from user@mydomain.com
maildomain mydomain.com
tls off
logfile /var/log/msmtp.log
and the php code for sendmail:
<?php mail('webuser@freemail.com', 'test', 'hi, this is a test!'); ?>
Here's the mail I received using the php mail function:
From - Fri Sep 25 00:21:41 2009
X-Account-Key: account6
X-UIDL: 1253830343.5295.mail6.worldserver.net,S=426
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:
Return-Path: <user@mydomain.com>
Delivered-To: webuser@freemail.com
Received: (qmail 5293 invoked by uid 89); 24 Sep 2009 22:12:23 -0000
Received: by simscan 1.3.1 ppid: 5252, pid: 5286, t: 0.5040s
scanners: attach: 1.3.1 clamav: 0.91.1/m:44/d:4513
Received: from unknown (HELO localhost) (user@mydomain.com@some-ip-address-i-dont-want-to-show)
by 0 with ESMTPA; 24 Sep 2009 22:12:22 -0000
To: webuser@freemail.com
Subject: test
hi, this is a test!
As you can see, the return address is correct, but the FROM envelope is missing the address.
Finally, here's the /var/log/msmtp.log entry:
Sep 25 00:21:39 host=smtp.mydomain.com tls=off auth=on user=user@mydomain.com from=user@mydomain.com recipients=webuser@freemail.com mailsize=58 smtpstatus=250 smtpmsg='250 ok 1254068455 qp 23429' exitcode=EX_OK
I also tried auto_from on in the config with the same results. What's wrong here?
Last edited by bitpal (2009-09-27 16:34:38)
Offline
Options auto_from (and from) set "envelope from" address; it's used only in dialog between SMTP client and server and has nothing to do with From: header you expect to find in your email. You just have to define the header in additional_headers parameter of PHP mail() function, like
mail('webuser@freemail.com', 'test', 'hi, this is a test!', 'From: "User" <user@mydomain.com>');
Offline
Great, that works!
Another thing: If I have several accounts in my msmtprc file how can I select the one I want when I call the mail function?
Offline
See Choosing an account section in msmtp's documentation and the fifth parameter of PHP mail() function and be creative
Offline
Great, that works!
Another thing: If I have several accounts in my msmtprc file how can I select the one I want when I call the mail function?
not sure how php fits in... but
msmpt -a accountName
works for me. and adding to the bottom of ~/.msmtprc:
default : accountName
will set accountName to be used when no -a is passed.
//github/
Offline
Pages: 1