Jump to content

Recommended Posts

Hello, I have problem with this script. This script is for newsletter system and writing emails to "mailing.txt" file. Problem is that its in line like this:

 

 mail@mail.commail@mail.commail@mail.com

 

and i need to have in lines like:

 

mail@mail.com
mail@mail.com
mail@mail.com

 

there is my script:

 

<?php
$email = $_POST['email'];
$file = fopen("mailing.txt", "a");
fwrite($file, "\n" . $email);
fclose($file);
header("Location: mailing_thankyou.php");
?>[code]

Thank you, have nice day.

Link to comment
https://forums.phpfreaks.com/topic/241327-php-script-problem/
Share on other sites

oh okay you're using windows..then you'll want

 

<?php
$email = $_POST['email'];
$file = fopen("mailing.txt", "a");
fwrite($file, $email."\r\n");
fclose($file);
header("Location: mailing_thankyou.php");
?>

 

or also

 

<?php
$email = $_POST['email'];
$file = fopen("mailing.txt", "at");
fwrite($file, $email."\n");
fclose($file);
header("Location: mailing_thankyou.php");
?>

Link to comment
https://forums.phpfreaks.com/topic/241327-php-script-problem/#findComment-1239630
Share on other sites

oh okay you're using windows..then you'll want

 

<?php
$email = $_POST['email'];
$file = fopen("mailing.txt", "a");
fwrite($file, $email."\r\n");
fclose($file);
header("Location: mailing_thankyou.php");
?>

 

or also

 

<?php
$email = $_POST['email'];
$file = fopen("mailing.txt", "at");
fwrite($file, $email."\n");
fclose($file);
header("Location: mailing_thankyou.php");
?>

 

Still the same. I tryed 3 "test@test.com" emails 1,2,3 and here is report of mailing.txt:

 

test1@test1.comtest2@test2.comtest3@test3.com

 

I tryed some choses of /n /r, thinks like that i found in google but still same problem.

 

Link to comment
https://forums.phpfreaks.com/topic/241327-php-script-problem/#findComment-1239636
Share on other sites

Just tested this and works, could also replace the three functions fopen, fwrite, fclose with file_put_contents.

 

$dir = '../test/test.txt';
$email1 = "test1@test1.com\r\n";
$email2 = "test2@test2.com\r\n";
$email3 = "test3@test3.com\r\n";
file_put_contents($dir, $email1, FILE_APPEND);
file_put_contents($dir, $email2, FILE_APPEND);
file_put_contents($dir, $email3, FILE_APPEND);

 

Has this in file test.txt (using windows)

test1@test1.com
test2@test2.com
test3@test3.com

Link to comment
https://forums.phpfreaks.com/topic/241327-php-script-problem/#findComment-1239646
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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