Knowledgebase: How To
Sending mail using PHP Mail function.
Posted by Joe Rebis (Import) on 17 September 2006 12:16 AM

 

This article describes how to make an adjustment to your PHP mail script for it to function properly on a Windows based server. It does not describe how to write a form and script to send mail. It assumes some knowledge of PHP.

On a Windows based server it is necessary to set the "sendmail_from" address explicitly in the PHP.ini file*. This will properly set the Return-Path variable in the header and is not necessarily the FROM address displayed on an email address. If the Return-Path is not specified, the email may be considered spam or malformed by most hosts. Especially on common free email servers. Since most hosts, including us, will not provide you with direct access to the PHP.ini file*, you will need to set it in your script directly. Additionally, it would be incorrect for the host to specify a generic email address.

 

To set this parameter explicitly in your script you must use the ini_set() option.

ini_set("sendmail_from", "you @ your_hosted_domain.com");

 

The email address you specify should be a hosted domain on our system. Please note you should remove the added spaces between the @ sign.

Here is a sample script:

$to = 'someone @ yahoo.com';

$subject = 'the subject';

$myemail = 'you @ your_hosted_domain.com';

$myname = 'Joe Smith';

$message = 'Your Message';

$headers = "From: ".$myname." <".$myemail.">\r\n";

ini_set("sendmail_from", "you @ your_hosted_domain.com");

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

 

Note: in this example with are choosing to display Joe Smith instead of the email address when the recipient views the message in their email client. It is generally not recommended to do this on Windows based systems for both the FROM and TO email addresses.

*Note: If you need only to make a modification to the "sendmail_from", you can use the .user.ini file method, explained in the Knowledge base Article "How to setup PHP website to be able to send email by creating a .user.ini file"

 

Also SeeEmail Settings POP3 / IMAP | Check email online | Email Troubleshooting | Adding an email to your hosting account WINDOWS / LINUX

Contact Support

If you are still having issues, please contact us for further help.
1-877-EPHOST1 | support@ephost.com

 

 

(526 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).

Copyright © 2015 EPhost, Inc. All rights reserved.