I am trying to send email from my contact us form on my site.

At the moment i am testing it on my localhost, with these php.ini settings:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = pop3.mail.dk
; http://php.net/smtp-port
smtp_port = 110

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = svenne50@hotmail.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =

Is this correct set up?

What should "sendmail_from" be? Im not sure I am doing that correct, or?

My processing script looks like this:

// Contact subject
$subject = $_POST['subject'];
// Message from sender
$message = $_POST['detail']; 

// Mail of sender

$mail_from = $_POST['customer_mail'];

// Name of sender
$name = $_POST['name'];

// Enter your email address
$to ='svenne50@hotmail.com';

$headers = "MIME-Version: 1.0 . \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 . \r\n";
$headers .= "From: $mail_from . \r\n";
$send_contact = (mail($to, $subject, $name, $message, $headers));

echo "Tak for din forespørgsel.";
//header('location: index.php');
else {
echo "ERROR";

I get the succes confirmation efter submitting, but the email never arrives in my inbox.

Does someone know how this can be?


6 Years
Discussion Span
Last Post by digital-ether

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =

The PHP.ini comments are a bit misleading. The sendmail_path directive must have a correct path to a sendmail executable, or else PHP will not know which path to use for sendmail in the command line. The "for unix only", refers solely to the arguments.

You need to downwload a sendmail clone for windows, and place the path to the executable as the value for sendmail_path. PHP will then invoke this executable through the command line passing it the email to be sent.


Sorry, I misread your post. I thought you wanted to configure sendmail. If you want to use SMTP then you need to configure the domain and port of your SMTP server. You have configured the POP3 server which is different.

The SMTP server for mail.dk is:

fpo.mail.dk 25

You can find this by running the command though the shell:

dig mx mail.dk

This will give you the list of mail severs for a domain.

I ran the command and got this:

$ dig mx mail.dk

; <<>> DiG 9.6-ESV-R4 <<>> mx mail.dk
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29847
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;mail.dk.                       IN      MX

mail.dk.                1835    IN      MX      10 fpo.mail.dk.

;; Query time: 1 msec
;; WHEN: Sun May 15 03:10:00 2011
;; MSG SIZE  rcvd: 45

Then tried to send an email via SMTP:

$ telnet fpo.mail.dk 25
Connected to fpo.mail.dk.
Escape character is '^]'.
HELO 220 Welcome to fpo.mail.dk!
HELO local.domain.com
250 fep23 says HELO to
MAIL FROM: jim@example.com
250 MAIL FROM accepted
RCPT TO: sam@example.com
550 5.2.1 relaying to example.com not allowed, see http://postmaster.tdc.dk/publish.php?id=25170
RCPT TO: sam@mail.dk
250 RCPT TO accepted

So as you can see, the SMTP server does not allow relaying emails. This means you can only send emails to mail.dk in your tests. Most SMTP servers are configured this way to prevent spamming. They will require authentication before relaying email.
For your testing, it is best to send to your-username@mail.dk and if that works, you can set up user/pass for and authenticated SMTP connection to send mail to anyone.

Edited by digital-ether: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.