Jump to content

PHP Mail Syntax Problem


mayfair

Recommended Posts

Hello Guys

 

Im trying to send a 'mock order' email to be imported into our database using its built-in web import process. Ive spent so long on this now and think im close to the point of cracking this, but im stuck on a few little things that are stopped me from being able to test this properly.

 

When sending the email, I need to send it with a command at the beginning of the TO: field so that the database knows it's a web import email and to check/filter it before importing. I literally just need to send the email with the following appearing in the TO: field:

 

$to = "GM-WEBIMPORT <[email protected]>"

 

As it is, that never reaces the wi address. If i CC myself in on a copy, I can see that it is sent to me and GM-WEBIMPORT only - no email address on the end of it. Is there a certain syntax I need to follow to stop this from breaking at the space and send to the full address?

 

Thanks in advance.

 

Link to comment
https://forums.phpfreaks.com/topic/175484-php-mail-syntax-problem/
Share on other sites

Try using the $headers option instead, so something like:

 

... 

$headers .= 'To: GM-WEBIMPORT <[email protected]>' . "\r\n";
$headers .= 'From: The Sender <[email protected]>' . "\r\n";
$headers .= 'Bcc: [email protected]' . "\r\n";

...

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

 

Hello bothwell, thanks for your input.

 

Using the headers option gives me the following error:

 

PHP Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in E:\inetpub\wwwroot\company.com\html\new\content\payment.php on line 203

Yes I tried that, still have the same problem. Actually, if I try sending it like that I get a 550: Delivery is not allowed to this address error unless I turn on sending from external to external accounts on my hmail server.. which I obviously don't want to do!

 

Can't believe something so simple is stopping me after ive spent weeks writing the whole ordering system lol  ::)

It is a bit strange. According to php.net the format you're trying to send in is perfectly valid.

 

Have you tried it on a live email server at all? It might just be some sort of config issue with your hMailserver (I'm assuming you're using that in a dev enviro).

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.