Reputation: 39
I am using this script to generate a regular-changing email address with qmail
#!/bin/bash
##### change these settings #####
qmailpath="/your/path/to/.qmail-"
wwwpath="/your/path/to/html/tempmail"
host="@my.host"
prefix="temp-"
length="16"
##### do not change the following #####
oldmail="$qmailpath"$(cat "$wwwpath" | cut -d@ -f1)
newmail="$prefix"$(date +%s%N | md5sum | cut -c 1-"$length")
rm "$oldmail"
touch "$qmailpath$newmail"
echo -n "$newmail$host" > "$wwwpath"
I am using this php command to include the email address in my webpage:
<a href="mailto:<?php include('tempmail');?>"><?php include('tempmail');?></a>
It works fine, but if I take a look at the source code of the webpage, I recognize a strange line break:
<a href="mailto:temp-rpwaa44hff5kch8smfuv3@myhost
">temp-rpwaa44hff5kch8smfuv3@myhost
</a>
Where does this come from and how can I remove it?
UPDATE: I updated the script and added -n
after echo
. Now it works.
Upvotes: 0
Views: 163
Reputation: 929
It appears there is an end of line, to solve this in PHP use rtrim(file_get_contents())
like so:
<a href="mailto:<?php echo rtrim(file_get_contents('tempmail'));?>"><?php echo rtrim(file_get_contents('tempmail'));?></a>
From the php manual:
file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.
On the bash side of things, it is echo that introduces a newline, so if you don't want it just use echo -n
:
echo -n $TEMPMAIL"@myhost" > /home/user/html/tempmail
Upvotes: 2