PDA

View Full Version : Need help with ee commerce email option.


Ed Rotberg
29th of January 2004 (Thu), 00:34
Hi,

I've set up the $localaccount, $localemail, $remoteaccount, $remoteemail variables in my mail.php file. Right now they both point to my own email address, but with a different name for $localaccount than for $remoteaccount.

Whenever I try to use this feature I get the message "Sending email did not succeed."

I've tried to figure out what is wrong, but I'm not really a php wizard. Is there some way to debug why the send_mail function (which calls php's mail function) is returning an error? Is there something obvious I'm doing wrong with the account/email information?

I'm running EE 1.5 beta 5 fix pack 2.

Any help would be appreciated.

Thanks,

= Ed =

Ed Rotberg
30th of January 2004 (Fri), 21:10
Pekka? Anyone have any ideas on this?

= Ed =

TomKa
31st of January 2004 (Sat), 01:41
Exist the accounts $localemail and $remoteemail on your server?
On my settings i have the same email address for both variables, also this email is an existing account on my server. Works well without problems.

Pekka
31st of January 2004 (Sat), 03:43
Yes, the problem may happen if you do not have the exact (send) account on your server.

Ed Rotberg
31st of January 2004 (Sat), 11:22
Yes, the problem may happen if you do not have the exact (send) account on your server.

For testing I'm using my own email account - the account that I got the notification just now that someone had replied to this post. However, my email account does require password authentication. Could that be the problem?

Hmmm. Isn't there some way to debug specifically what's going wrong? To find out what exactly the error is?

= Ed =

Pekka
31st of January 2004 (Sat), 15:35
Yes, the problem may happen if you do not have the exact (send) account on your server.

For testing I'm using my own email account - the account that I got the notification just now that someone had replied to this post. However, my email account does require password authentication. Could that be the problem?

Can be. The PHP mail function does not do login, but it should still work on localhost without it.

I'll have to write SMTP client in PHP same way I did ftp client - it's the only way to handle all this properly. It's all documented in http://www.faqs.org/rfcs/rfc821.html :roll:

Hmmm. Isn't there some way to debug specifically what's going wrong? To find out what exactly the error is?

= Ed =

What I always do is see http://fi2.php.net/manual/en/function.mail.php

Ed Rotberg
31st of January 2004 (Sat), 20:26
OK, I found out what was causing the problem, but not how to fix it properly - although i do have a very suitable work-around.

In data.php, the key line in the send_mail function looks like this:
return (@mail(""" . $to_name . "" <" . $to_email . ">", $subject, $message, $headers));

The first parameter that is built up is the php mail() "string to" parameter, and from the looks of it, you are trying to build it up as so:

"John Doe" <jdoe@bogusmail.com>

Unfortunately, for whatever reason, in my version of php (I believe it's 4.3.4) under Windows 2000 Server, the actual address is somehow not getting included in the string passed to the mail() function and all that is getting passed is "John Doe".

I found this out by building up a message to output in that send_mail() function that is the same as that string. I spent a bit of time playing around with it in order to get it to work properly, but quickly became frustrated as it is obviously not working the way it is supposed to work.

:idea: My simple work-around is to use the following line instead of the one shown above:

return (@mail($to_email, $subject, $message, $headers));

This simply uses jdoe@bogusmail.com as the "string to" parameter for the mail() function. Not as pretty, but just as effective.

I really wish I knew what was causing the string concatination problem. Maybe I'll work on it some more at a later date, but it's really not at all necessary - the mail is only going to me anyhow :)

Thanks for the pointers. I hope this helps someone else.

= Ed =

Pekka
1st of February 2004 (Sun), 10:32
Well done! :lol:

Ed Rotberg
1st of February 2004 (Sun), 11:37
I did manage to figure out how to format the string to get the desired format of:

"John Doe" <jdoe@bogusmail.com>

In order to do that I switch to single quotes instead of double, and used the < alternate to the '<' character. So the new format would look like this:

return (@mail('"' . $to_name . '" <' . $to_email . '>', $subject, $message, $headers));

Unfortunately, this still fails when sent using the php mail() function.

FWIW, I'm running Apache 2.0.48 which, IIRC, isnot actually supported my EE. :oops:

= Ed =