Jump to content

FROM address in mail() function


salman_ahad@yahoo.com

Recommended Posts

I need to use the FROM address in mail function. I don't know what is the proper syntax.

 

$to_email = "[email protected]";
$from_email = "[email protected]";
$subject = "Greetings";
$message = "Hi";

mail($to_email, $subject, $message);           //proper syntax to use FROM address???

Link to comment
https://forums.phpfreaks.com/topic/182556-from-address-in-mail-function/
Share on other sites

$to_email = "[email protected]";
$Headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]';
$subject = "Greetings";
$message = "Hi";

mail($to_email, $subject, $message, $Headers);           //proper syntax to use FROM address???

 

Next time, just check the documentation

 

http://php.net/manual/en/function.mail.php

I am already using Headers to attach my email template.

 

I am still getting mail as From : [email protected]  (I am still not getting From : [email protected])

 

My code

 

<?php
$to_email = "[email protected]";
$Headers = 'From: [email protected]' . "\r\n" .
$subject = "Greetings";
$message = ''
. '<table width="676">'
. 	'<tr>'
. 		'<td width="30" height="52"><img src="http://www.ideatoceo.com/emails/Side.gif" width="30" height="50" alt="Corner" /></td>'
. 		'<td width="600"><img src="http://www.ideatoceo.com/emails/Top.gif" width="600" height="50" alt="Top" /></td>'
. 		'<td width="30"><img src="http://www.ideatoceo.com/emails/Side.gif" width="30" height="50" alt="Corner" /></td>'
. 	'</tr>'
.  	'<tr>'
.		'<td><img src="http://www.ideatoceo.com/emails/Side.gif" width="30" height="200" alt="Lside" /></td>'
.		'<td> <p>Asalam-alikum,</p>'
.		'<p>This EID get 30 calling minutes to Saudia Arabia FREE from <a href="http://www.rebtel.com/u/0131701413" target="_blank">Rebtel </a> , for New or Returning users. </p>'
.		'<p>Visit add credit and use the promotional code "Saudi30".</p>'
.		'<p><img src="http://www.ideatoceo.com/emails/Center.gif" alt="Center" width="600" height="8" align="absbottom" /></p>'
.		'<p>Awareness brought to you by <a href="http://www.ideatoceo.com/islam-emails.php" target="_blank">IdeatoCEO </a></p></td>'
.		'<td><img src="http://www.ideatoceo.com/emails/Side.gif" width="30" height="200" alt="Rside" /></td>'
.	'</tr>'
.	'<tr>'
.		'<td><img src="http://www.ideatoceo.com/emails/Side.gif" width="30" height="25" alt="Corner" /></td>'
.		'<td><img src="http://www.ideatoceo.com/emails/Bottom.gif" width="600" height="25" alt="Bottom" /></td>'
.		'<td><img src="http://www.ideatoceo.com/emails/Side.gif" width="30" height="25" alt="Corner" /></td>'
.	'</tr>'
.'</table>'
.'<table>'
  	.'Forwarding Hadith to friends is now easy, visit <a href="http://www.ideatoceo.com/islam-emails.php" target="_blank">IdeatoCEO </a><br />'
.'<a href="http://www.ideatoceo.com/islam/emails.php" target="_blank">Unsubscribe</a> from the distribution<br />'
.'	<br />'
.'www.ideatoceo.com | 192 allen ave | Saint Louis | MO | 63104 <br  />'
.'</table>';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to_email, $subject, $message, $headers);
?>

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.