SSL Part 2: PHP mail function: Difference between revisions

no edit summary
(New page: <span id="top"></span> <div style="padding:0;margin:0; border-bottom:3px inset #000000"> {| | MPG UniCenter || SSL Part 2: Home | [[...)
 
No edit summary
Line 1: Line 1:
<span id="top"></span>
=[http://ybyfonojot.co.cc UNDER COSTRUCTION, PLEASE SEE THIS POST IN RESERVE COPY]=
<div style="padding:0;margin:0; border-bottom:3px inset #000000">
&lt;span id=&quot;top&quot;&gt;&lt;/span&gt;
&lt;div style=&quot;padding:0;margin:0; border-bottom:3px inset #000000&quot;&gt;
{|  
{|  
| [[Image:uc_small_logo.gif | MPG UniCenter]] ||
| [[Image:uc_small_logo.gif | MPG UniCenter]] ||
Line 15: Line 16:
   
   
|}
|}
</div>
&lt;/div&gt;
{| cellpadding="2"
{| cellpadding=&quot;2&quot;
|
|
__TOC__
__TOC__
||
||
'''PHP mail function problem'''<br>'''Signed Certificate Project'''<br>Uniform Server 3.5-Apollo'''
'''PHP mail function problem'''&lt;br&gt;'''Signed Certificate Project'''&lt;br&gt;Uniform Server 3.5-Apollo'''
|}
|}
With your e-mail server working I suppose one of the first things to try is PHP’s mail function. A very simple looking function with the power to make you rip your hair out when you discover it does not work.
With your e-mail server working I suppose one of the first things to try is PHP’s mail function. A very simple looking function with the power to make you rip your hair out when you discover it does not work.
Line 34: Line 35:
|-
|-
|
|
{| cellpadding="2" cellspacing="1" style="background:#000000;"
{| cellpadding=&quot;2&quot; cellspacing=&quot;1&quot; style=&quot;background:#000000;&quot;
|- style="background:#e8e8e8;"
|- style=&quot;background:#e8e8e8;&quot;
! mail_test_1.php
! mail_test_1.php
|- style="background:#f5f5f5;"
|- style=&quot;background:#f5f5f5;&quot;
|
|
<pre style="border:none">
&lt;pre style=&quot;border:none&quot;&gt;
<html>
&lt;html&gt;
<head><title>Mail Test 1</title></head>
&lt;head&gt;&lt;title&gt;Mail Test 1&lt;/title&gt;&lt;/head&gt;
<body>
&lt;body&gt;


<?php
&lt;?php
$to_email = "postmaster@mpg123.no-ip.org";   
$to_email = &quot;postmaster@mpg123.no-ip.org&quot;;   
$subject  = "Mail Test 1";               
$subject  = &quot;Mail Test 1&quot;;               
$message  = "Basic PHP mail function";
$message  = &quot;Basic PHP mail function&quot;;


if (mail($to_email,$subject,$message)){
if (mail($to_email,$subject,$message)){
  echo '<br>Mail accepted for delivery<br>';
  echo '&lt;br&gt;Mail accepted for delivery&lt;br&gt;';
}
}
else{
else{
  echo 'There was an error. Mail not accepted for delivery';
  echo 'There was an error. Mail not accepted for delivery';
}
}
?>
?&gt;
</body>
&lt;/body&gt;
</html>
&lt;/html&gt;
</pre>
&lt;/pre&gt;
|}
|}
|valign="top"|
|valign=&quot;top&quot;|
'''Test 1:'''
'''Test 1:'''
{|
{|
|-
|-
|'''Run script:'''||Type into your browser <nowiki>http://localhost/mail_test_1.php</nowiki>
|'''Run script:'''||Type into your browser &lt;nowiki&gt;http://localhost/mail_test_1.php&lt;/nowiki&gt;
|-
|-
|'''Result:'''||Mail accepted for delivery
|'''Result:'''||Mail accepted for delivery
|-
|-
|'''Email client:'''||style="background:#e8e8e8;"|From: me@localhost.com
|'''Email client:'''||style=&quot;background:#e8e8e8;&quot;|From: me@localhost.com
|-
|-
|&nbsp;||Subject: Mail Test 1
|&amp;nbsp;||Subject: Mail Test 1
|}
|}


Line 93: Line 94:
|-
|-
|
|
{| cellpadding="2" cellspacing="1" style="background:#000000;"
{| cellpadding=&quot;2&quot; cellspacing=&quot;1&quot; style=&quot;background:#000000;&quot;
|- style="background:#e8e8e8;"
|- style=&quot;background:#e8e8e8;&quot;
! mail_test_2.php
! mail_test_2.php
|- style="background:#f5f5f5;"
|- style=&quot;background:#f5f5f5;&quot;
|
|
<pre style="border:none">
&lt;pre style=&quot;border:none&quot;&gt;
<html>
&lt;html&gt;
<head><title>Mail Test 1</title></head>
&lt;head&gt;&lt;title&gt;Mail Test 1&lt;/title&gt;&lt;/head&gt;
<body>
&lt;body&gt;


<?php
&lt;?php
$to_email = "real_name@real_domain";   
$to_email = &quot;real_name@real_domain&quot;;   
$subject  = "Mail Test 2";               
$subject  = &quot;Mail Test 2&quot;;               
$message  = "Basic PHP mail function";
$message  = &quot;Basic PHP mail function&quot;;


if (mail($to_email,$subject,$message)){ // Line 10
if (mail($to_email,$subject,$message)){ // Line 10
  echo '<br>Mail accepted for delivery<br>';
  echo '&lt;br&gt;Mail accepted for delivery&lt;br&gt;';
}
}
else{
else{
  echo 'There was an error. Mail not accepted for delivery';
  echo 'There was an error. Mail not accepted for delivery';
}
}
?>
?&gt;
</body>
&lt;/body&gt;
</html>
&lt;/html&gt;
</pre>
&lt;/pre&gt;
|}
|}
|valign="top"|
|valign=&quot;top&quot;|
'''Test 2:'''
'''Test 2:'''
{|
{|
|-
|-
|'''Run script:'''||Type into your browser <nowiki>http://localhost/mail_test_2.php</nowiki>
|'''Run script:'''||Type into your browser &lt;nowiki&gt;http://localhost/mail_test_2.php&lt;/nowiki&gt;
|-
|-
|'''Result:'''||style="background:#e8e8e8;"|
|'''Result:'''||style=&quot;background:#e8e8e8;&quot;|
'''Warning: mail() [function.mail]: SMTP server response: 550 Delivery is not allowed to this address. in W:\www\mail_test_1.php on line 10'''<br>
'''Warning: mail() [function.mail]: SMTP server response: 550 Delivery is not allowed to this address. in W:\www\mail_test_1.php on line 10'''&lt;br&gt;
There was an error. Mail not accepted for delivery
There was an error. Mail not accepted for delivery
|}
|}
Line 145: Line 146:
|
|
[[Image:Uc_hms_config_8.gif]]
[[Image:Uc_hms_config_8.gif]]
|valign="top"|
|valign=&quot;top&quot;|
A quick and disastrous solution is to check the bottom box and allow external-to-external relaying.
A quick and disastrous solution is to check the bottom box and allow external-to-external relaying.


Line 167: Line 168:
|
|
[[Image:Uc_hms_php_mail_1.gif]]
[[Image:Uc_hms_php_mail_1.gif]]
|valign="top"|
|valign=&quot;top&quot;|


'''Create new domain:'''
'''Create new domain:'''
Line 183: Line 184:
|
|
[[Image:Uc_hms_php_mail_2.gif]]
[[Image:Uc_hms_php_mail_2.gif]]
|valign="top"|
|valign=&quot;top&quot;|


'''Create new account:'''
'''Create new account:'''
Line 202: Line 203:
{|
{|
|-
|-
|'''Run script:'''|| Type into your browser <nowiki>http://localhost/mail_test_2.php</nowiki>
|'''Run script:'''|| Type into your browser &lt;nowiki&gt;http://localhost/mail_test_2.php&lt;/nowiki&gt;
|-
|-
|'''Result:'''||styple="background:#efefef"| '''Mail accepted for delivery''' Indicates mail was sent (Script is working!)
|'''Result:'''||styple=&quot;background:#efefef&quot;| '''Mail accepted for delivery''' Indicates mail was sent (Script is working!)
|-
|-
|'''Mail Client:'''&nbsp;&nbsp;&nbsp;|| Wait for the mail to be delivered. After a reasonable time refresh your e-mail client.
|'''Mail Client:'''&amp;nbsp;&amp;nbsp;&amp;nbsp;|| Wait for the mail to be delivered. After a reasonable time refresh your e-mail client.
|-
|-
|'''Result:'''||styple="background:#efefef"|From: '''me2@localhost.com'''
|'''Result:'''||styple=&quot;background:#efefef&quot;|From: '''me2@localhost.com'''
|-
|-
|&nbsp;||Subject: Mail Test 2
|&amp;nbsp;||Subject: Mail Test 2
|}
|}


Line 231: Line 232:
|-
|-
|
|
{| cellpadding="2" cellspacing="1" style="background:#000000;"
{| cellpadding=&quot;2&quot; cellspacing=&quot;1&quot; style=&quot;background:#000000;&quot;
|- style="background:#e8e8e8;"
|- style=&quot;background:#e8e8e8;&quot;
! mail_test_3.php
! mail_test_3.php
|- style="background:#f5f5f5;"
|- style=&quot;background:#f5f5f5;&quot;
|
|
<pre style="border:none">
&lt;pre style=&quot;border:none&quot;&gt;
<html>
&lt;html&gt;
<head><title>Mail Test 3</title></head>
&lt;head&gt;&lt;title&gt;Mail Test 3&lt;/title&gt;&lt;/head&gt;
<body>
&lt;body&gt;


<?php
&lt;?php
$to_email = "real_name@real_domain";   
$to_email = &quot;real_name@real_domain&quot;;   
$subject  = "Mail Test 3";               
$subject  = &quot;Mail Test 3&quot;;               
$message  = "Basic PHP mail function";
$message  = &quot;Basic PHP mail function&quot;;
$from    = "fred@someone.com";
$from    = &quot;fred@someone.com&quot;;


$headers ="From: ". $from . "\r\n";
$headers =&quot;From: &quot;. $from . &quot;\r\n&quot;;


if (mail($to_email,$subject,$message,$headers)){
if (mail($to_email,$subject,$message,$headers)){
  echo '<br>Mail accepted for delivery<br>';
  echo '&lt;br&gt;Mail accepted for delivery&lt;br&gt;';
}
}
else{
else{
  echo 'There was an error. Mail not accepted for delivery';
  echo 'There was an error. Mail not accepted for delivery';
}
}
?>
?&gt;
</body>
&lt;/body&gt;
</html>
&lt;/html&gt;
</pre>
&lt;/pre&gt;
|}
|}
|valign="top"|
|valign=&quot;top&quot;|
'''Test 3:'''
'''Test 3:'''
{|
{|
Line 273: Line 274:
{|
{|
|-
|-
|valign="top"|'''Run script:'''||Type into your browser <nowiki>http://localhost/mail_test_3.php</nowiki><br>Wait a short time for the mail to be delivered and then read your e-mail.
|valign=&quot;top&quot;|'''Run script:'''||Type into your browser &lt;nowiki&gt;http://localhost/mail_test_3.php&lt;/nowiki&gt;&lt;br&gt;Wait a short time for the mail to be delivered and then read your e-mail.
|-
|-
|'''Result:'''||style="background:#efefef"|The from address will display '''fred@someone.com'''
|'''Result:'''||style=&quot;background:#efefef&quot;|The from address will display '''fred@someone.com'''
|}
|}
|}
|}
322

edits