Jump to content

How to email without the broken function email()?


Krisando

Recommended Posts

Hey, i'm needing to use email in a php script, but i've had no luck getting this working.. Even with perfectly given details.

 

Is there another way which would let me email?

 

I've tried using smtp details from live, gmail, isp email... All of which say it's send, but is not the case.

 

The function is extremely broken, is there an alternative? Or some way to get this working?

 

Kris.

Link to comment
Share on other sites

The mail function is NOT broken.

Wherever I read, it's not working because of spam. Everything is blocking it from working, therefore broken?

 

Is that a question? The mail function is not broken. You may have something on your server misconfigured, but I assure you, your problem lies elsewhere. Are you sending the correct headers? Sending a from a valid email address? Are your DNS entries configured properly?

Link to comment
Share on other sites

 

Are you sending the correct headers?

Are headers necessary with this function? Sending a from a valid email address? Are your DNS entries configured properly?

 

This is the entire header, with just about everything in it.

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n 
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

mail("YourEmail", $subject, $message, $from);

 

Sending a from a valid email address?

Does the email account have to be on the hosing pc?

 

Are your DNS entries configured properly?

I scanned the xampp folder for string "dns", nothing like this seems to exist in apache/php. If it's dns in network settings, yes it's configured.

Link to comment
Share on other sites

This is the entire header, with just about everything in it.

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n 
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

mail("YourEmail", $subject, $message, $from);

 

The mail function is:

mail( $to, $subject, $message[, $additional_headers [, $additional_parameters ]] );

 

Not:

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

 

============================================

 

Also, according to RFC 2822 - the format for the From address should be:

$visitor <$visitormail>

 

Not:

$visitor ($visitormail)

 

This may help you with the headers too: http://www.webmasterworld.com/forum88/13383.htm

Link to comment
Share on other sites

If your using mail() on xampp (like I do, and have for eons) then, in the script you are using type this on the very top of the file:-

 

<?php

error_reporting(E_ALL):

//Rest of your code

//and the mail function

 

Then when you run the script and the mail function is invoked, there should now be an error message printed to screen, stating about a failure to connect to the smtp server, this therefore confirms that the mail function has been called and is attempting to send an email.

 

Ergo: mail() funciton - Functional.

 

Upload to your test server, send an emial, wait 10 mins, check the spam folder & the inbox - result, email arrived.

 

Be aware, there is no method of checking that the sending has actually worked, we just take php's word for it that the mail has been sent, the only real confirmation is the email in the inbox.

 

Rw

Link to comment
Share on other sites

I use xampp too and this is what did the trick for me I edited php.ini I added my ISP (the one I pay to be on the internet smtp.myisp.co.uk it can look something like this:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.myisp.co.uk
; http://php.net/smtp-port
smtp_port = 25

 

although i don't use smtp (as far as i know), i found it somewhere on the internet applied it and it worked.

Link to comment
Share on other sites

I use xampp too and this is what did the trick for me I edited php.ini I added my ISP (the one I pay to be on the internet smtp.myisp.co.uk it can look something like this:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.myisp.co.uk
; http://php.net/smtp-port
smtp_port = 25

 

although i don't use smtp (as far as i know), i found it somewhere on the internet applied it and it worked.

 

smtp refers to the protocol of email so you are indeed using it.

 

Your isp also sux because they are allowing there servers to be used without any authentication being required.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.