Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hiya all,

 

Please take a look at the following code which is part of a user registration process.

 

if (mysqli_affected_rows($dbc) == 1)
		{
			//If it did, then send the activation email to the user
			$body = "Thankyou for saving a quote with Di's Soft Furnishings. To activate your account, and view your quote, please click on this link:\n\n";

			$body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a";

			mail($trimmed['email'], 'Account Registration Confirmation', $body, 'From: Di@DisSoftFurnishings.co.uk');

		}

Please also refer to my recent post regarding Mercury mail. In that post I said that I've created 2 mail accounts in Windows mail both with localhost.com (using the alias settings in Mercury Mail). I can send an email from one test account to the other and back again and it works fine.

 

However. I filled in the registration form on my registration page (name, email, password1 and password2). I used an email address which is one of the test accounts mentioned above. I ran it. It updated the user in the DB OK, so I know that bit worked. It came up with no errors. Yet, no email was received.

 

Where can I go from here? I'm not even clear where to look. I don't know whether it's my code or my Mercury Mail setup. My feeling is that it can't be the Mercury Mail setup because I can send emails between the two test accounts. If I can't work it out I guess I'll have to test everything else, put it live (with an external host) and then test the email functionality. But that doesn't seem the correct way to do it.

 

Thanks for any suggestions anyone can give.

Paul

Link to comment
Share on other sites

Hi Paul,

I think I was having the same problem like you. I also tried to send email from my newuser@localhost account to my @gmail.com account and vice versa.

I think you should never use mercury mail for production purposes, if I'm wrong, are you using any mail client like Mozilla Thunderbird.

I visited your last post where you embedded a you tube video. I also searched for that and searched the blog to get mercury mail working. They too talked about scary things like IP's, setting, ports etc. Nothing worked, It's very complex.

 

And the logic you used of making two user like test1@localhost and test2@localhost is not bad, I also tried it. I sent a email through php code using mail() functions the 'Mercury Core Process' window in the Mercury mail server showed that the email was sent. And the message It self can be watched via a mail client like Mozilla Thunderbird.

Link to comment
Share on other sites

Morning Shoun and all,

 

I'm not using Thunderbird, I've created my 2 test email addresses in Windows Mail. I used Windows Mail because it's local as opposed to Gmail etc. (I can't get Mercury Mail to send emails 'externally'). I set up these users in Windows Mail so that, like you, I could see that my mail() code worked. I can't. Is there a way to 'tell' Mercury Mail who to send the email from, i.e. from test1@localhost.com to test2@localhost.com? Where are localhost emails sent from?

 

I must confess, as a beginner without much knowledge or experience of these things, that there seems to be a hole in the development process here. XAMPP, phpMyAdmin and MySQL are superb resources to test PHP, and I suspect other things that I haven't come accross yet. However there seems, from posts in this and other forums, no solid, reliable platform to test auto-email functions. I'm about to start Larrys advanced PHP5 book where, I understand, there is a section on using PHP to create HTML and CSS styled emails. I'm looking forwards to learning that, as with the project that I'm working on I would like to send statements to clients using data from their orders etc and make them look a bit more attractive that plain text. However, as it stands, I can't test them until they get into a live environment with a hosts mail server.

 

Am I missing something? This can't be how others do it?

 

Any thoughts?

Paul

PS Apologies if you're pick up a feeling of frustration here.

Link to comment
Share on other sites

Paul,

Good Morning(though it's afternoon here :P )

 

Let me tell you and everyone about my experience about Mercury Mail Server.

 

You know what, I thought I could use my XAMPP as a live server, and use Mercury Mail Server as Server like Gmail or Yahoo

I thought business would be good. B)

 

I spent three days to get Mercury Mail even sending a mail. First I created two test user namely newuser@locahost, newuser2@localhost (n.b not .com) from Configuration > Manage local users

 

I only wrote a PHP code like this

<?php mail('newuser2@localhost', 'subject', 'the body', 'From: newuser@localhost'); ?> 

 

It responded

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

 

Failed to connect to mailserver :angry: But Mercury was open what could happen. I struggled to find out may be mercury was open but offline. File menu > Enter offline mode. But It is online.

I clicked File menu > Enter offline mode

Then again clicked File menu > Leaver offline mode, Then the mail was send with no errors or warnings. There is a window in the Mercury Mail Server called 'Mercury Core Process'. Where you can see sending email, to or from but not the body. To see the body use a mail Client like Mozilla Thunderbird.(Dude!!! you should use a Mail Client, and it is the best and free....)

 

 

So, Next. If I can send mail between two localusers may be I can send between a localuser to gmail. I couldn't. I searched the internet, viewed youtube videos but nothing worked. I configured a lot in the mercury mail. Nothing......so i can't send message from inside to outside but inside to inside.

 

I learned that the mail() function is not the perfect way to send mail, there is a class in the PEAR library blah..blah..blah

In this case Larry will be the one who can show us the light.

Link to comment
Share on other sites

Paul,

Hey Don't ask me about PEAR :wacko: , I'm an absolute Idiot in PHP, I just know Like openGL Library for Game Programming, stdio.h, iostream.h for C,C++ programming PEAR is a Industry standard Library for Efficient PHP application.

It has lots of PHP functions and classes(not like built-in mail() or is_array())which are used by most experienced PHP programmer and the most popular. That's all I know.

If someone want to use it he has to download it and installed, But it's not for the babies.

Anyone correct me if I'm wrong.

 

Greetings

Shoun

Link to comment
Share on other sites

 Share

×
×
  • Create New...