Jump to content
Larry Ullman's Book Forums

Recommended Posts

I don't use the PHP mail() function much, so I don't know the details, but I have seen a lot of posts/articles about issues and incompatibilities with it (especially when sending to Gmail/Hotmail address, etc.).

 

I have a site I am building with a couple of forms that need to be sent to an email address, and all I really need to do is take the submitted data, scrub it for any issues, and then relay that information to the provided email address.

 

Given the (apparent) issues with the PHP mail() function, what would be a decent alternative, and if possible, where could I find some documentation for that alternative?

 

Thank you.

Link to comment
Share on other sites

I've never had any problems sending to hotmail or Gmail and I did do a lot of live testing to those accounts a couple years back. Sorry I don't know any other mail functions, except Zend's. But that would be PHP (I imagine). What sort of problems do you have? Just that they don't get delievered?

Link to comment
Share on other sites

You were right, Jonathon. I was able to send an email to my Gmail address fine. It automatically threw the email in my spam box, but other than that, I got it fine.

 

I still wish there were an easy way (or I should say, I wish I knew how) to send emails via XAMPP.

Link to comment
Share on other sites

Hi,

 

I'm an XAMPP user. running on w7 x64 as localhost testing server. I'm gonna have to ask you questions regarding your question.

 

1. You actually sent out an email as mentioned using php mail() function. You followed it up by asking I wish I knew how to on xampp.

Well. Where did you actually used the function that was sent out to your gmail spam? I was pressuming a hosted testing server.

 

In any case, the mail() function would work on your XAMPP locally. First you have to enable the "mercury" mail server on your XAMPP control panel (even if is just started ordinary and not a service).

 

with a running mercury server all you need to do is write a test email.php script and you'll progress from there.

 

<?php

// simple email test

 

ini_set("SMTP", "stmp.myisp.com"); // setting up your localhost to send via you ISP's SMTP settings

ini_set("sendmail_from", "myaccount@myisp.com"); // this is necessary if your ISP requires username upon SMTP

ini_set("smtp_port", "25"); // well the default port is 25 but if your ISP's SMTP port isn't 25, you can actually change it here.

 

// then the simple mail() function test.

 

$to = 'mygmailmail@gmail.com'; // receipient

$from = 'From: myxampp@mypc.com'; // sender

$subject = 'Hello World!'; // Subject line

$message = 'This is an email test.'; // your message.

 

// Again, this is just probably be the simplest form of testing out your mail() function.

 

mail($to, $subject, $message, $from);

 

echo 'If I haven\'t prompted an error report, I\'d better check my inbox or spam.';

 

?>

2. 2nd Q., what type of email are you trying to send out?

The example above will just be plain text. you can use the mail() function for delivering emails in text formats and HMTL as well. And even with attachments. Again you can progress as soon as you are able to use your xampp locally if that is what you want.

 

<?php

// simple HTML email test

 

ini_set("SMTP", "stmp.myisp.com"); // setting up your localhost to send via you ISP's SMTP settings

ini_set("sendmail_from", "myaccount@myisp.com"); // this is necessary if your ISP requires username upon SMTP

ini_set("smtp_port", "25"); // well the default port is 25 but if your ISP's SMTP port isn't 25, you can actually change it here.

 

// then the simple HTML mail() function test.

 

$to = 'mygmailmail@gmail.com'; // receipient

$from = 'From: myxampp@mypc.com'; // sender

$subject = 'Hello World! (HTML Version)'; // Subject line

 

 

$message = '

<html>

<head>

</head>

<body>

<p>This is an HTML formatted email.</p>

</body>

</html>';

 

 

$headers = 'MIME-Version: 1.0' . "\r\n";

$headers . = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers . = 'Cc: carbonme@gmai.com' . "\r\n"; // if you want to have a cc.

$headers . = 'Bcc: blindme@gmail.com' . "\r\n"; // if you wanted to have a blind carbon copy

$headers . = 'From: HartleySan<myemailadd@mypc.com>' . "\r\n";

 

 

mail ($to, $subject, $message, $headers);

 

 

echo 'If I haven\'t prompted an error report, I\'d better check my inbox or spam.';

 

?>

  • Upvote 1
Link to comment
Share on other sites

MrLeche, that's very useful information. Thank you. I knew I had to do something with the Mercury Mail server, but online information is scarce, and I have always been at a loss on what to do.

 

I will look into that sometime soon and try to get it working. Thank you. Also, it might be useful to use HTML, etc. in emails in the future, so that's good info as well.

 

Also, I realized that the reason my emails were going to the Gmail Spam box was because the sender was labeled as "Unknown". I used the "From: " part for the headers, but it didn't seem to work. I'll look into it more this evening.

 

Thank you.

Link to comment
Share on other sites

Nah. for me, I never came to de-mystify which falls to legit and junk. I had my personal email account for over eight years now, Those were the days when spams are still more popular as meatloaf in a can as opposed to junk email right now. But they still fall into junk/spam most of the time. Particulary when it is your first time sending out to a new email address that you haven't send out before.

Link to comment
Share on other sites

I have started using Zend Server on Windows 7 and can send mail by just changing the SMTP line in php.ini to my ISP and using a valid email in the headers. I could never get the mail to work when using Linux (Ubuntu) and xampp.

Link to comment
Share on other sites

 Share

×
×
  • Create New...