Jump to content

email unknown sending :S


EchoFool

Recommended Posts

Hey

 

When ever i send my mail from a php mail function i get "unknown sender" in my gmail account but i clearly put who it was from in my headers and subject is also filled in yet subject doesn't come through either... my mail function is simple like this:

 

        // Send the email.
        $Email = $Var;
        $subject = 'Reminder';
        $headers = 'From: My only server!';
        $message = 'I am sending you a reminder! ';
        mail($Email, $subject, $message, $headers);

 

What am i doing wrong ?

Link to comment
Share on other sites

dear friend you try like this i hope it will work

 

 

<?php

$to      = 'nobody@example.com';

$subject = 'the subject';

$message = 'hello';

$headers = 'From: webmaster@example.com' . "\r\n" .

    'Reply-To: webmaster@example.com' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();

 

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

?>

 

Link to comment
Share on other sites

what am i doing wrong?

Yes, you are not sending the from address, is it supposed to appear there?

 

As well, you should set the MIME header to prevent spam traps and allow html if you wish so.

$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";

 

 

Link to comment
Share on other sites

The From: header must be a valid email address at the sending mail server. You are lucky that your mail server even sent it or that the gmail server accepted it.

 

If you want to send directly to your gmail mailbox, you will need to use SMTP authentication, which the php mail() function does not support. You would need to use one of the many php mailer classes.

Link to comment
Share on other sites

What problem are you trying to solve? Sending an email directly to your own mailbox at an ISP without using your web host's mail server or sending emails to any arbitrary email address that visitors to your site have provided and if so, what email server do you want to use as the sending mail server?

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.