Send Mail from Diffenet Account PHP

darkpunkcalob

New Member
Messages
22
Reaction score
0
Points
0
So, I have my mail script out and fine, it works, but it sends the mail from my user@boru.x10hosting.com... I need it to come from my user@domain.co.cc mail account.

I know there is a way to change it from the php.ini file, but I dont have access to that, so is there a feature of code im missing to do this?
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
PHP:
<?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);
?>
Use the $headers variable to control the address the email originates from. Copied straight from here
 

darkpunkcalob

New Member
Messages
22
Reaction score
0
Points
0
PHP:
<?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);
?>
Use the $headers variable to control the address the email originates from. Copied straight from here


Thanks, but tried that, still comes up as user@boru.x10hosting.com
 

DeadBattery

Community Support Team
Community Support
Messages
4,018
Reaction score
120
Points
0
PHP:
<?php
$to = 'youremail@x10email.com'; /*change this to your email*/
$subject = 'the subject';
$message = 'hello';
$headers = 'From: user@domain.co.cc' . "\r\n" .
    'Reply-To: user@domain.co.cc' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>
Try uploading that as a PHP file (editing the top email address) and loading it. It should send you an email.
(I just put changed a couple values from lemon-tree's post.
 

gichan

New Member
Messages
64
Reaction score
0
Points
0
By adding from address to header you cannot change the address of sending the mail. It just add a email header. But it will show the recipient as the email was sent from the address you entered to the header. But really the email will sent from the address: user@server.x10hosting.com
 

darkpunkcalob

New Member
Messages
22
Reaction score
0
Points
0
The header doesn't work btw, and yeah, i want to change where its coming from, not where to to reply to.
 

DeadBattery

Community Support Team
Community Support
Messages
4,018
Reaction score
120
Points
0
As you said, the mail() method falsifies the From address; it won't always be right.
The only way to make it work is to connect to an email account and send an email. I'm not sure if there is a way to do that or not.
 

fortwienix

New Member
Messages
9
Reaction score
0
Points
0
try to do
PHP:
ini_set('sendmail_from', 'me@domain.com');
and optional:
PHP:
ini_set("SMTP","smtp.domain.com" );
before calling mail(). If that doesn't work, you can make an SMTP connect to the server where your mail account is hosted. That needs of course username and password in your script that is opening the connection.
 

darkpunkcalob

New Member
Messages
22
Reaction score
0
Points
0
try to do
PHP:
ini_set('sendmail_from', 'me@domain.com');
and optional:
PHP:
ini_set("SMTP","smtp.domain.com" );
before calling mail(). If that doesn't work, you can make an SMTP connect to the server where your mail account is hosted. That needs of course username and password in your script that is opening the connection.


That didnt work either :(

Here is the complete script:

HTML:
<html>
<title>SMS System | SMS Sent</title>
<head>
<style type="text/css">
body {background-color: black; color: white}
a {color: red}
p {margin-left: 20px}
</style>
</head>
<body>
<center>
<?php

if ($_POST["carriers"] == "vtext") $to = $_POST["num"]."@vtext.com";

if ($_POST["carriers"] == "att") $to = $_POST["num"]."@txt.att.net";

if ($_POST["carriers"] == "lilman") $to = $_POST["num"]."@cingularme.com";

if ($_POST["carriers"] == "next") $to = $_POST["num"]."@messaging.nextel.com";

if ($_POST["carriers"] == "tmo") $to = $_POST["num"]."@tmomail.net";

if ($_POST["carriers"] == "rtb") $to = $_POST["num"]."@messaging.sprintpcs.com";

if ($_POST["carriers"] == "bst") $to = $_POST["num"]."@myboostmobile.com";

if ($_POST["carriers"] == "vdf") $to = $_POST["num"]."@sms.vodafone.it";

$subject = "";
$from = "sms-noreply@darkjournal.co.cc";
$message = $_POST["mess"];
$headers = 'From: sms-noreply@darkjournal.co.cc' . "\r\n" .
    'X-Mailer: PHP/' . phpversion(); 
ini_set('sendmail_from', 'sms-noreply@darkjournal.co.cc');
mail($to,$subject,$message);

?>
<h1>SMS Sent!</h1><br>
<a href="http://darkjournal.co.cc/start-sms.php">Go Back to Home</a>
</center>
</body>
</html>
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
Code:
mail($to,$subject,$message);

You set the headers, but you never actually told mail to use them.

Try:

Code:
mail($to,$subject,$message,$headers);
 
Top